Sanguino & SPI

I am trying to port a working application from Arduinos to Sanguinos, and the ported app is hung up in its use of SPI to communicate with an SD card. The SPI port designators are hard-coded into the mmc library, and I thought that it would be sufficient to go into mmc.cpp and replace

// PORTB pin numbers
// arduino D10
#define SS    2

// arduino D11
#define MOSI  3

// arduino D12
#define MISO  4

// arduino D13
#define SCK    5


// PORTB pin numbers
// Sanguino D03, Arduino D10
#define SS    3   // was 2

// Sanguino D05, was Arduino D11
#define MOSI  5   // was 3

// Sanguino D06, was Arduino D12
#define MISO  6   // was 4

// Sanguino D07, was Arduino D13
#define SCK   7   // was 5

That doesn’t do the trick. With this change in the library, mmc::initialize hangs somewhere in its first call to sendCommand, and I don’t understand the strategy of mmc enough to promote my thrashing to tinkering. My guess is that there is a hidden hardware issue, rather like the one discussed by in the thread, but I need a little more help than I can glean from that. Thanks in advance.

My look at the old code suggested that the SS pin was arbitrary, so long as it was somewhere on the B port. I used pin 3 because pin 4 was in use by another part of my application, and I was not impressed by any need to have the SPI interface use adjacent pins. The 644 pinout diagrams that I'd seen (e.g., at did not show a specific SS pin.

I shouldn't have settled for a second-hand description of the chip. As seen on page 2 of the datasheet (, SS is hardwired on the 644 (as it happens, to pin 4), just as it is on the various Arduino chips.

I will revise my app to avoid pin 4, and then re-edit my Sanguino version of mmc.cpp so that it properly assigns the SS pin. I am posting now (before making these changes & testing) to keep others from spending any time thinking about the problem.

Proper assignment of the SS pin is not sufficient. With that change, mmc::initialize fails because the first call to sendCommand (i = sendCommand(GO_IDLE_STATE, 0, 1);) fails. Any suggestion appreciated.

Ignore previous message. SS = 4 is indeed the solution; I had a wiring error on top of that.