Hello,
I don't know if anyone else faced this problem, but recent I came across an SD card that only works with SPI quarter speed... (had to use the QuickStart example of the SdFat library to figure that out).
I did not notice any method in the SD library to change the SPI speed. It can be achieved by a little modification in the library.
In SD.h file, replace
boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN);
with
boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN, uint8_t spiSpeed = SPI_HALF_SPEED);
and in SD.cpp file,replace
boolean SDClass::begin(uint8_t csPin) {
/*
Performs the initialisation required by the sdfatlib library.
Return true if initialization succeeds, false otherwise.
*/
return card.init(SPI_HALF_SPEED, csPin) &&
volume.init(card) &&
root.openRoot(volume);
}
with
boolean SDClass::begin(uint8_t csPin, uint8_t spiSpeed) {
/*
Performs the initialisation required by the sdfatlib library.
Return true if initialization succeeds, false otherwise.
*/
return card.init(spiSpeed, csPin) &&
volume.init(card) &&
root.openRoot(volume);
}
After these modifications any of the following methods can be used to start the SD object.
SD.begin();
SD.begin(cspin);
SD.begin(cspin, spiSpeed);
spiSpeed (which is optional) can be SPI_FULL_SPEED, SPI_HALF_SPEED or SPI_QUARTER_SPEED as supported by SD2Card class.
Hope this helps.