I have a project that uses an Arduino Due, and it reads from and writes to an SD card. I use low-capacity SD cards (256mb to 2gb). Every so often, I find a card that works fine in Windows, but absolutely will not work with my project. Just to keep things simple, I've tried the CardInfo sample program. With this "bad cards", it fails. Now I've discovered that an entire batch (100) of Nokia 128mb cards do not work. They work fine in Windows, but every single one fails with CardInfo.
BTW, I've also tried this with an Uno, and it exhibits the same behavior, so it's not unique to the Due.
Any ideas what would make some cards different? Anything I can do different to make them work?
Have you formatted the cards in the proper manner? If you have that many duds, it sounds very much like you haven't. There is a sticky on this at the head of the forum. Also, is your card module running at the right voltage?
Yes, I am formatting them with the SD formatter from the SD association. We're not talking about a half-dozen cards, I have successfully used hundreds of low-capacity cards, but have problems with about 150 cards, all Nokia 128mb or 256mb. All of the cards that cause problems have similar markings (the text on the card is vertical, not horizontal.) I don't believe the cards are "duds", but perhaps a different type of card?
I just checked a bunch of Nokia 128mb cards. Without exception cards with horizontal text worked, cards with the text printed vertically did not. Obviously there is something different about the cards.
kb0wwp:
Without exception cards with horizontal text worked, cards with the text printed vertically did not. Obviously there is something different about the cards.
I noticed in the CardInfo sample program it reports the "card type". The cards that work are SD2. I see in the code there is also SD1, SDHC, and Unknown. I have not been able to find a Windows utility that will report the card type. I'm assuming the cards that don't work are a different type.
If you're aware of any Windows utility that would report some details on these cards, let me know what it is.
I googled it yesterday and got that result. I tried the program recommended (h2testw) but it did not appear to give me the information I was looking for.
Since you can't read these cards neither on a DUE nor on a UNO, I would try and change parameters in SPI_CSR.
See page 703 of Sam3x datasheet, SPI_CSR register is a Read/Write register. First, Read SPI_CSR after initialization of the SD card device:
uint32_t __SPICSR = SPI0->SPI_CSR[0];
Then, once you know what default parameters you have, modify them one at a time and see the result.
An example of a parameters selection:
// Data transfer parameters
SPI0->SPI_CSR[0] = SPI_CSR_CPOL // Inactive state value of SPCK is logic level one
| SPI_CSR_NCPHA // Data is captured on the leading edge of SPCK and changed on the following edge
| SPI_CSR_CSNAAT // Chip select active after transfer
| SPI_CSR_BITS_12_BIT // Bits per transfer
| SPI_CSR_SCBR(100) // slowest bit rate
| SPI_CSR_DLYBS(100); // Maximum delay from NPCS falling edge (activation)
// to the first valid SPCK transition
I broke down and spent $8.50 on eBay for a micro SD/network shield. That works with all of my non-working cards. The previously non-working cards are all invariably showing in CardInfo as "SD1". Now I need to figure out what's difference between the shield card reader and the SD module I'm using.
Your module looks very similar to the module in the Instructable link except that your module does not have the voltage regulator to step down 5V to 3.3V.