SDHC microSD card and SPI initialization

三世轮回 提交于 2019-12-04 03:25:18
Walid BR

You shouldn't use CMD1 to initialize SDHC cards; as said in the SD Card specification:

In any of the cases CMD1 is not recommended because it may be difficult for the host to distinguish between MultiMediaCard and SD Memory Card.

Some controllers (newer and higher capacity cards mostly) will simply stay in IDLE if you issue CMD1 to them. You should first issue CMD8 0x1AA after the reset (CMD0), and then use CMD55 + ACMD41.

tl;dr to initialize the card you should:

  1. CMD0 arg: 0x0, CRC: 0x95 (response: 0x01)

  2. CMD8 arg: 0x000001AA, CRC: 0x87 (response: 0x01)

  3. CMD55 arg: 0x0, CRC: any (CMD55 being the prefix to every ACMD)

  4. ACMD41 , arg: 0x40000000, CRC: any

  5. if response: 0x0, you're OK; if it's 0x1, goto 3.

Note that most cards require steps 3/4 to be repeated, usually once, i.e. the actual sequence is CMD0/CMD8/CMD55/ACMD41/CMD55/ACMD41 - to be sure, try it n times (select n within your reason), and assume fail if it doesn't.

Also, note that you should assert S̲S̲ (aka CS) low at least before and after CMD0 - and, in reality, probably always when sending any command to the SD card.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!