Problems with microSD Shield

Hi guys,

I have problems to make the microSD shield work.

I have already tried several versions of the sdFat library, and several Arduino boards(MEGA2560, ATmega1280 and Atmega328), but the result is always the same. For the QuickStart.pde from the examples for sdFat there is always an error in card.init.

What may I try additionally to find out what causes the problem?

I have also tried different microSD cards of 512 Mb and 2 Gb sizes.

Is there a chance that I have a faulty shield?

Thanks in advance.

The micro SD card that SFE sells does not use the default Chip Enable IO pin. You must modify the constructor to use the correct pin. Likely you are doing this. But, what you must also do is define the default CS pin to be an output and not use the pin. Not documented, but very much needed.

Now it kind of makes sense that SFE did not use the default CS so that other cards could also use the SPI bus. But the sdFat library was not designed for this. They still want the default SPI CS as an output.

One solution (the one I took) was to cut the CS line on the sdCard and reroute it back to the default CS. SFE should have designed the card to bring the CS line to a series of solder jumpers to allow the user to change the pin assignments in a simpler way.

In formation on this is not placed in obvious places. If you search the SFE forums you will find mention of this issue.

Hope this helps.

Thank you for suggestion. But I don’t want to start modifying the board now. Please let me know if I got it wrong.

Here is a quote from the shield information page:

If you decide to use one of the many open source FAT libraries (like FAT16 or SDFat) make sure to change the code to reflect the location of the CS pin. Most libraries assume the CS pin is connected to D10; this will have to be changed to D8. Also for the libraries to work pin D10 will have to be set as an output in the ‘setup()’ section of your sketch.

So I guess that this problem must have been considered. I tried to call pinMode(10, OUTPUT) in the setup() function, but still have the same problem.

Does anyone has this board working, just with the sdFat library that can be downloaded through the sparkfun website?

This is from readme.txt with the SDFat library:

SdFat assumes chip select for the SD card is the hardware SS pin.  On a
168/328 Arduino this is pin 10 and on a Mega this is pin 53.  If you are
using another pin for chip select you will need call
Sd2Card::init(sckRateID, chipSelectPin) with second parameter set to the
chip select pin.  

If you have a shield like the SparkFun shield that uses pin 8 for chip
select you would change the line:
  sd.init(SPI_HALF_SPEED);
to
  sd.init(SPI_HALF_SPEED, 8);
  
If the example uses
  sd.init();
change it to:
  sd.init(SPI_FULL_SPEED, 8);


You can also edit Sd2Card.h and change the default value for chip select.
Replace SS_PIN with the new value for chip select in the following definition.

/** The default chip select pin for the SD card is SS. */
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;