Hi,
I am using the SPI port to interface a SD card and two other devices. The problem is that I can interface each one individually working very well. However, when I try to integrate all together is not working. The SD Card throw the following error:
error: card.init failed
SD error: 2,1F
Using other SD Card gives to me:
error: volume.init failed
SD error: 3,1D
I am using this, on the setup section:
// initialize SPI port
void spi_initialize(void) {
SPCR = (1<<SPE) | (1<<MSTR); // spi enabled, master mode
clr = SPSR; // dummy read registers to clear previous results
clr = SPDR;
}
// SPI specific for master/slave communication
pinMode(MOSI, OUTPUT);
pinMode(SCK, OUTPUT);
pinMode(MISO, INPUT);
// Looked at page 11 of this: http://www.atmel.com/dyn/resources/prod_documents/doc2585.pdf
pinMode(10, OUTPUT);
digitalWrite(10, HIGH); //physical SS pin high before setting SPCR
// Slaves as outputs
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
// magnetometer specific pins
pinMode(9, OUTPUT);
//reset pins
digitalWrite(9, LOW);
// slaves deselected
digitalWrite(6, LOW); // rtc idle mode
digitalWrite(7, HIGH); // datasheet HIGH = in idle mode
Serial.begin(9600); // downlink baud rate
spi_initialize(); // initialize SPI port
// initialize the SD card
if (!card.init(SPI_FULL_SPEED, 8)) error("card.init failed");