SDHC SPI 写入问题
我一直在尝试使用 LPC1766 SPI 外围设备有一段时间了,现在我陷入了一个问题,我在任何地方都找不到答案。
问题是:SDHC 卡未按预期响应写入和读取命令。
基于 Chan 的流程图和 NXP 应用笔记的初始化一切正常。我可以区分卡片版本,读取 OCR、CID、CSD 并确定它们的大小。
在这一步之后,我开始每秒写入单个块并将其读回以检查数据完整性。在金士顿 SDHC 4GB Class 4 卡上,我可以发送第一个写入命令,但在第二个命令上,该卡甚至不向 CMD24 应答(0x00 或 0x01)。使用 SanDisk 4GB Class 4 卡,结果有所不同,每个命令都由卡应答,但读回数据时我只得到零(我确信我没有写零)。如果我使用 SDSC 卡,一切正常。
我知道 SDHC 是块寻址而不是字节寻址,并且我需要为 SDHC 发送带有 CCS 的 ACMD41。我还知道时钟频率不是问题(使用 400KHz 启动,然后使用 20MHz 写入/读取),因为我刚刚打开 CRC 检查,并且所有卡都在接受命令和数据。如果我停止计算 CRC,所有卡都会拒绝命令和数据。
I've been trying to do an SD card interface with the LPC1766 SPI peripheral for a while and right now I'm stuck in a problem that I couldn't find the answer anywhere.
The problem is: SDHC cards are not responding to write and read commands as expected.
Everything works fine on the initialization that was based on Chan's flowchart and on an NXP application note. I can differentiate the cards versions, read the OCR, CID, CSD and determine their sizes.
After that step I start writing single blocks every one second and reading it back to check the data integrity. On a Kingston SDHC 4 GB Class 4 card I can send a first write command but on the second one the card does not even answer (0x00 or 0x01) to the CMD24. With a SanDisk 4 GB Class 4 card the results are different, every command is answered by the card, but I get only zeroes when reading the data back (I'm sure I'm not writing zeroes). If I use SDSC cards, everything works fine.
I'm aware that SDHC are block addressed and not byte addressed and that I need to send ACMD41 with the CCS on for SDHC. I also know that the clock frequency is not an issue (using 400 KHz to start and then 20 MHz to write/read), because I just turned on the CRC checking and all cards are accepting the commands and data. If I stop calculating the CRC all cards reject commands and data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如何连接 SD 卡?根据模式/状态,SD(HC) 卡需要一个外部上拉电阻。如果没有它,你读到的为零,所以这可能是你的问题。
How do you connect your SD card? Depending on the mode/state the SD(HC) card needs an external pull-up resistor. Without that you read zero, so that may be your problem.