I've seen several of you have managed to get SD cards going, but I've been working on this for a week now (learning about SD protocol and FAT to begin with then writing software) and am hoping someone might be able to give me a push with a problem I've been stuck on for two days now.
I have the following:
//initialization command (74 clock cycles for initialization sequence) SendCommand(CARD_CLOCK_INIT, ARG_DONT_CARE,&Response); // Reset card SendCommand(CMD0, ARG_DONT_CARE,&Response); // Set 2.7-3.3V operation, should also return 0x1AA if (SendCommand(CMD8,0x1AA,&Response) == FAIL) return FAIL; // Ensure the card's not busy before continuing if (sdBusyWait() == FAIL) return(FAIL);
Up to here, all seems perfect. No errors at all:
Then I get here:
// Ask for the CID if (SendCommand(CMD2, ARG_DONT_CARE,&Response) == FAIL) return FAIL;
Although I get no errors per se, the data just does not look right. I get this back:
0x1b534d30 0x30303030 0xba00b977 0x1b534d30
As far as I can see from the spec, this should contain various fixed bytes such as ASCII for SD which is 0x5344 - it clearly doesn't.
I then ask for the relative address:
if (SendCommand(CMD3, ARG_DONT_CARE,&Response) == FAIL) return FAIL;
This always, but always, gives me 0002 in the upper word. No errors, but it seems wrong. As far as I can tell this shouldn't be the same each time?
After that, when I try to initialise the card with the address 2 (or 0x2000) as the value to send with CMD7 (unless I reissue it, when it returns incremental values), I just keep getting non-responses.
I have a Sandisk 2GB micro SD card, I am reasonable sure the set-up is right as my CMD8 always returns the correct value for example.
Anyone able to point me in the right direction please? I have done around a zillion Google searches and tried a gazillion different things; I have a suspicion the issues really start with CMD2 and that return data not being quite right. Why though, and what I should be doing different I am at an utter loss to explain.