SDHC microSD卡和SPI初始化

发布于 2024-12-14 10:53:18 字数 632 浏览 2 评论 0原文

我有一张 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸢与 2024-12-21 10:53:18

您不应该使用CMD1来初始化SDHC卡;正如 SD 卡规范中所述:

在任何情况下都不建议使用 CMD1,因为主机可能很难区分 MultiMediaCard 和 SD 存储卡。

如果您向某些控制器(主要是更新型和更高容量的卡)发出 CMD1 ,它们将简单地保持在 IDLE 状态。
您应该在重置 (CMD0) 后首先发出 CMD8 0x1AA,然后使用 CMD55 + ACMD41

tl;dr 要初始化卡,您应该:

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

  2. CMD8 arg:0x000001AA,CRC:0x87(响应:0x01代码>)

  3. CMD55 arg:0x0,CRC:任意(CMD55 是前缀每个 ACMD)

  4. ACMD41 ,arg:0x40000000 code>,CRC:任何

  5. 如果响应: 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:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文