SDHC卡SPI初始化
我正在开发一个目前仅支持 SDSC v1 卡的嵌入式系统。由于找到小于 2 GB 的卡变得越来越困难,我正在尝试添加对 SDHC 卡的支持。与卡的通信是通过 SPI 总线完成的。
所以这就是我初始化卡的方法:
- 发送 CMD0。卡返回0x1
- 发送CMD8 + 0x1AA。卡返回 0x1 和 0x1AA
- 发送 ACMD41。卡返回 0x0。
后来我看了MBR,发现在0x30处有一个FAT16分区LBA。但是,从该地址 (0x30*512) 读取扇区会返回 0x01 0x09 的重复...
- 发送 ACMD41 时,我发送命令 id 0x69。正确吗?或者我应该先发送 CMD55,然后发送 CMD1?
- 图表 1 显示我需要在发送 ACMD41 后发送 CMD58,可能还需要发送 CMD16。有必要吗?我无需执行这些操作就能够读取有效的 MBR。
I'm working on an embedded system that currently only supports SDSC v1 cards. As it's getting harder and harder to find cards less than 2 GB, I'm trying to add support for SDHC cards. The communication with the card is done via the SPI bus.
So here is what I'm doing to initialise the card:
- Send CMD0. Card returns 0x1
- Send CMD8 + 0x1AA. Card returns 0x1 and 0x1AA
- Send ACMD41. Card returns 0x0.
Afterwards, I read the MBR and figured out that there is a FAT16 partition at 0x30 LBA. However, reading a sector from that address (0x30*512) returns a repetition of 0x01 0x09...
- When sending ACMD41, I'm sending command id 0x69. Is it correct? Or should I send CMD55 and then CMD1?
- A diagram 1 shows that I need to send CMD58 and possibly CMD16 after sending ACMD41. Is it necessary? I was able to read a valid MBR without doing them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“ACMD”命令都需要 CMD55 后跟相关命令。
例如,对于命令 ACMD41:
不要忘记将 0b01000000 与第一个参数进行 OR 运算。实际命令不是 55,而是
55|0b01000000
(0b01110111
,十进制119
)。我在 SD_command 函数本身中执行此操作。连接 SD 卡是一件非常痛苦的事情,所以不要放弃。祝你好运!
"ACMD" commands all require a CMD55 followed by the relevant command.
For example, for command ACMD41:
Don't forget to OR in 0b01000000 to the first argument. The actual command isn't 55, it's
55|0b01000000
(0b01110111
, decimal119
). I do it in the SD_command function itself.Interfacing to SD cards is a HUUUUUGE pain, so don't give up. Good luck!