Sharing SPI (WAV Shield + MEGA +WiFly) - WiFly/WAV cable sel

I’m trying to get the Adafruit WAV shield, WiFly shield and Arduino MEGA to work together.

Problem:

The WAV shield has to be jumpered in exactly the same way as the WiFly shield to work with the Mega since they both share the SPI.

Mega pin 53 to shield pin 10

Mega pin 51 to shield pin 11

Mega pin 50 to shield pin 12

Mega pin 52 to shield pin 13

In my setup the WAV shield libary cable select has been modded to pin 49 and the WiFly shield is using pin 53.

I can initialize either shield separately fine. I can toggle between the WAV shield and WiFly at runtime…BUT for some reason I can’t toggle back to the WAV shield, after toggling the WiFly shield…And if I initialize the WiFly shield first, and can’t toggle the WAV shield at all…

Here’s a picture of my board setup and specs to give you a better idea what I’m working with (in the pic the cable select pin for WAV shield is at 33, it’s been moved to 49):

  • Arduino MEGA 2560

  • WiFly Shield

  • SpeakJet Shield

  • Adafruit WAV Shield

http://www.suniljohn.com/labs/dogsoflat … rduino.jpg

Snippets of my code:

#define SSWAV 49 //cable select pin for WAV shield
#define SSWIFLY 53 //cable select pin for WIFLY shield

void setup() {
  
  Serial.begin(9600);
  
  setupWAVANDWIFLY();

}

void setupWAVANDWIFLY()
{
  pinMode(SSWAV, OUTPUT);
  pinMode(SSWIFLY, OUTPUT);

  digitalWrite(SSWAV, HIGH);
  digitalWrite(SSWIFLY, HIGH);
}

//this enables the cable selection pin for WiFly shield
void enableWiFlyShield()
{
  digitalWrite(SSWAV, HIGH);
  digitalWrite(SSWIFLY, LOW);
}

//this enables the cable selection pin for WAV shield
void enableWAVShield()
{
  
  //digitalWrite(10, HIGH); //physical SS pin high before setting SPCR
  digitalWrite(SSWIFLY, HIGH);
  digitalWrite(SSWAV, LOW);
}

I’ve been using this fork of the WiFly library which support Arduino 1.0:

https://github.com/bobbrez/WiFly

Has anyone had success at using the WiFly shield with another SPI device? I wonder if it’s hogging the SPI bus, like some other ethernet shields I’ve read about. Is there some thing wrong with my code? I would appreciate any tips on how to debug this.

I have no experience with this setup. The schematic shows that the CS line of the WiFly shield is directly connected to Pin 10 of the Arduino. In your sketch you don’t setup this Pin. Try pinMode(10, INPUT) to ensure you don’t have the chip select for the WiFly shield put to ground accidentally. I would do the same with the other pins interconnected (11, 12, 13).