My Arduino Mega. I added the micro sd shield from SparkFun. I downloaded the FAT add-in and tried to run the example. I can’t make it work. Does it work with the MEGA? I put in a FAT 16 formatted 2 GB mico SD card. Any ideas?
You need to realize that sd cards are 3.3v.
You interface them like this:
http://www.sparkfun.com/commerce/tutori … ials_id=65
Also if you are using the FAT16 library (not SDuFat), see the docs and note about SPI bus speeds. FAT16 doesn’t like resistor dividers at full speed (use a line buffer, also in the docs).
Forgive my ignorance if I am wrong here, but it lloks like the shield is using the 3.3v power from my mega. Isn’t the Sparkfun shield kind of plug-and-play?
No, its 3.3v power supply only. The data lines and clock are unmodified.
I think we have covered this here before, the sparkfun shield still needs signal mods to work properly (sadly we try to get SF to fix this).
I found that the FAT16 library, and a line buffer chip, like a 74hc4050n(other types will work as documented in the FAT16 docs) is very simple to breadboard, and worked flawlessly.
The example fat16 code for this shield has a few problems:
-
fat16.cpp has a comment in FAT::Write that said it will always write to EOF. It will not because the second argument to fat_seek_file was 0 and not a pointer to an offset as it needs to be.
-
fat16_example.pde says read(buffer) will read sizeof buffer. The actual read routine will read 512 bytes regardless of the size of the buffer.
-
When the test file gets >512 bytes the example will fail.
-
fat16.cpp should be rewritten to: a) return more error indications b) take size args, rather than assume strings c) have seek function.
I’ve fixed the items above. Let me know if you want it posted somewhere.
I’m successfully using this code with a shield that takes regular SD cards instead of microSD cards. The SD shield can get its power from the 3.3v supply on the Duemilenove board. This code works much better than the filelogger/nanofat code that came with the SD shield. The nanofat code takes 300 milliseconds on every write call. This code takes less than 2 milliseconds.
The only advantage to the nanofat code is that it is 9000 bytes smaller than this code.
The Nov release of FAT16 works fine. I did not write it, I just use it.
http://code.google.com/p/fat16lib/downloads/list
I see he has a newer version.
Code size -vs- features is a constant tradeoff.
Thanks, motopic. I was unaware of the project code on google.
I might be a little dense and not seeing this, but where in the fat16lib/sdfatlib does it talk about hardware setup? All I see is how to use the code.
But based on this discussion some like like the [Gravitech MicroSD adaptor should work find. Is the SS pin in the SdFat config the sam as the CS pin on microsd? That can be any pin on the arduino, the others are required pins for spi?](http://store.gravitech.us/micaad.html)
SirPoonga:
SdCard.h defines the pins used for the SSI protocol. You can change the defines there as needed for your particular card if they are not correct. I did not need to make any changes for the SD card shield that I’m using.
Hey, I had also faced the same issue some time ago when I got it. I tried to fix it but had no success in that. Then I asked many of my friends about this. But they also couldn’t help properly. Here I got the exact explanation and now I am ok with it. Thanks.