Problems with SPI and Multiple Shields (Pins are not colliding)

CrossRoads:
On the Mega, PB0, 53, must be set to an output even if not used for SS. That tells the Mega that is SPI master. If left as an input and it goes low, the Mega goes into SPI slave mode.

pinMode(53, OUTPUT);
I've did that as well, read it from the Arduino Website, However i was confused if there was a need to connect a cable to 53. As is already has a connection to the WiFi shield by the ICSP Header I assume it handles it already, since it worked previously with all devices.


SurferTim:
If you have any doubt, disable all SPI devices before starting any of them. After that, you should be able to start them in any order you want.

void setup() {

// disable wifi SPI
pinMode(SSWiFi, OUTPUT);
digitalWrite(SSWiFi, HIGH);

// disable wifi shield SD SPI
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);

// disable GD GPU SPI
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);

// disable GD SD SPI
pinMode(9, OUTPUT);
digitalWrite(9, HIGH);
 
// now start the SPI devices
GD.begin();
:
:
}

That i havent tried yet. I usually just unplugged the power and inserted it again as i was seeing problems with that.


dlloyd:
OK, so there's 5 SPI devices and it looks like there's no hardware conflicts:

Summary:

[b]CS Pin   Name      Board[/b]

D53      SS        Mega SPI master/salve (set as output for master) (reply#6)
D8      GPU SEL  Display
D9      SD SEL    Display
D4      SD SS    Wifi Shield
D10      Wifi      Wifi Shield



I now suspect (see reply#6) or a software conflict with the two SD cards. At least that's somewhere to investigate ... especially if the drivers are compatible. Perhaps the CS signal for one SD card isn't pulled high before the other SD card is selected.

Hmm, there you actually said something. Since there are 4 SPI Devices, A viable solusion might be if i did a state changes before calling any library functions. I've only tried to enable/disable the Wifi and GPU.
so if i did this

void GD_enable() {
//disable The WiFi shield:
digitalWrite(SSWifiSD, HIGH);
//enable the slave of the WiFi
digitalWrite(SSWifi, LOW);
//enable GPU & Disable SD of Display -- Presumable since the the GPU start of by sending via the GPU Port, i think it remains in this state. the SD should be switched by the functions that are using the SD Card, So if the state is the same as the originally the functions should work then.
etc etc
}

void enable_wifi(){
 //Same logic, disable everything else except for how the states was before.
}
}

Or alternatively. A Shield handler class that would recognize the previous select states before switching. which would make a few operations more, but would be compatible with other libraries as well.

An enable function for when switching between the shields would be appropriate for the way i do my code.

Will try this when i go home.