SDHC microSD卡和SPI初始化
我有一张 32 GB 金士顿 SDHC microSD 卡,必须通过 MSP430F2618 进行通信href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus" rel="noreferrer">SPI。我无法使用 CMD55 + ACMD41(bit30 设置为 1)来初始化它,正如 SD 规范文件中所述。有效的是这个序列:
CMD0, arg: 0 , CRC: 0x95 (response:0x01)
CMD8, arg: 0x1AA , CRC: 0x87 (response:0x01)
CMD1, arg: 0x40000000, CRC: 0xFF (response:0x00)
我也用 8 GB SanDisk 卡尝试过,也适用。所以实际上,我在这里使用CMD1,而不是ACMD41,HCS位设置为1。但是,它不稳定,有时可以工作,有时不行。这可能与硬件有关。
卡用参数 0x40000000
响应 CMD1,这并不奇怪吗?
I have a 32 GB Kingston SDHC microSD card which has to communicate to MSP430F2618 via SPI. I was not able to initialize it by using CMD55 + ACMD41 (with bit30 set to 1), as it is described in SD specification paper. What works is this sequence:
CMD0, arg: 0 , CRC: 0x95 (response:0x01)
CMD8, arg: 0x1AA , CRC: 0x87 (response:0x01)
CMD1, arg: 0x40000000, CRC: 0xFF (response:0x00)
I tried it also with a 8 GB SanDisk card and works for that too. So actually, I am using CMD1 here, not ACMD41, with HCS bit set to 1. However, it is not stable, sometimes it works, sometimes it does not. This may be about hardware.
Is it not strange that cards are responding to CMD1 with argument 0x40000000
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该使用
CMD1
来初始化SDHC卡;正如 SD 卡规范中所述:如果您向某些控制器(主要是更新型和更高容量的卡)发出
CMD1
,它们将简单地保持在 IDLE 状态。您应该在重置 (
CMD0
) 后首先发出CMD8 0x1AA
,然后使用CMD55 + ACMD41
。tl;dr 要初始化卡,您应该:
CMD0
arg:0x0
, CRC:0x95
(响应:0x01
)CMD8
arg:0x000001AA
,CRC:0x87
(响应:0x01
代码>)CMD55
arg:0x0
,CRC:任意(CMD55
是前缀每个ACMD
)ACMD41
,arg:0x40000000
code>,CRC:任何如果响应:
0x0
,你没问题;如果是0x1
,则转到 3。请注意,大多数卡片需要重复步骤3/4,通常是一次,即实际序列是
CMD0
/CMD8
/CMD55
/ACMD41
/CMD55
/ACMD41
- 当然,尝试它n
次(在你的理由中选择n
),如果没有,则假设失败。另请注意,至少在
CMD0
之前和之后,您应该将 S̲S̲(又名 CS)断言为低电平 - 实际上,在向 SD 卡发送任何命令时可能总是如此。You shouldn't use
CMD1
to initialize SDHC cards; as said in the SD Card specification: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 useCMD55 + ACMD41
.tl;dr to initialize the card you should:
CMD0
arg:0x0
, CRC:0x95
(response:0x01
)CMD8
arg:0x000001AA
, CRC:0x87
(response:0x01
)CMD55
arg:0x0
, CRC: any (CMD55
being the prefix to everyACMD
)ACMD41
, arg:0x40000000
, CRC: anyif response:
0x0
, you're OK; if it's0x1
, 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 itn
times (selectn
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.