2
votes

I saw a lot of information about MMC/SD cards and I tried to make a library to read this (modifying the Procyon AVRlib).

But I have some problems here. I don't change the original code and tried here. My problem is about the initialization of an SD card. I have two here, a 256 MB and another 1 GB.

I send the init commands in this order: CMD0, CMD55, ACMD41, and CMD1.

But the 256 MB SD card only returns a 0x01 response for each command. I send the CMD1 a lot of times and the 256 MB SD card always returns only 0x01, never 0x00.

The 1 GB SD is more crazy... CMD0 returns with 0x01. Nice, but the CMD55 command responds with 0x05. At other times it responds with 0xC1 and also sometimes responds with 0xF0 with a 0x5F in the next interation...

Around the Internet there is information and examples, but it is a bit confused. Here in my project, I must use a 1 GB card and I'm trying with a microSD card with an SD adapter (I think that this is not the problem).

How do I fix this problem?

PS: My problem is like the problem in Stack Overflow question Initializing SD card in SPI issues, but the solution didn't solve my problem. The 1 GB SD card only returns 0x01 ever... :cry:

4
Is the "CMD0 returns with 0x01 ..nice but the CMD55 response with 0x05" part correct? If CMD1 return 0x01, then CMD55 is not valid.Clifford
@Openavr I am also facing almost the same issue, can you please tell me how did you solve this issue ?gpuguy

4 Answers

2
votes

Why do you need CMD1? And did you read the note below it, that says "CMD1 is a valid command for the thin (1.4 mm) standard size SD memory card only if used after re-initializing a card (not after power on reset)."?

About the 1 GB card, ideas that come to mind:

  • After every command (send command, get reply), do you send 8 dummy bytes before making CS high?
  • The values returned seem weird (0x05 doesn't have busy bit set, so WTF?), maybe there's a hardware issue?
  • Does the card work otherwise?
1
votes

A simple explanation of MMC/SD usage over SPI is provided here. I have used the associated FAT file-system library too and it works well.

1
votes

However, the solution may not work for some makes of cards. For such cards, you may have to edit the procedure/library. That may be why your 1 GB card acts differently -- it may be a different make of card. The SPI mode of certain cards may not be that popular for commercial equipment, and thus may be more deviated in specification by some card manufacturers.

If you bit bang the commands and clocks, you may have more control and confidence that those procedures are correct. That is useful because you need some solid ground to build on to progress bit by bit. I found that the <400 kHz 80 clocks was critical on one card, but could run at more than 2 MHz on another.

Try to progress one command at a time that is reliable for both cards.