简体   繁体   English

部分 SD 卡写入失败(CMD24 返回 CRC 错误)

[英]Some SD cards fail to write (CMD24 returns CRC error)

I'm using a PIC18 to write to SD cards via SPI.我正在使用 PIC18 通过 SPI 写入 SD 卡。 For many cards, this is working file BUT for some cards I pass the init process but when trying to write to the card, CMD24 returns 0x05 (which I believe is a CRC error)对于许多卡,这是工作文件,但对于某些卡,我通过了初始化过程,但是在尝试写入卡时,CMD24 返回 0x05(我认为这是 CRC 错误)

// send CMD24 - preparing for a 512 byte block
SD_command(CMD24, 0x0001, CMD24_CRC);
    
// read response
res1 = SD_readRes1();  //This returns 0x05 for some cards!

I have used CMD59 - CRC_ON_OFF with parameter 0x00 to turn of CRC, and the command seems to complete.我已经使用 CMD59 - CRC_ON_OFF 和参数 0x00 来关闭 CRC,并且该命令似乎已完成。 Is there something I am missing?有什么我想念的吗?

I read a comment of someone on a forum, who spent one week looking for an error in this code.我在论坛上读到某人的评论,他花了一周时间寻找此代码中的错误。 In his case, he found that with some sd cards, he has to put a valid crc in the sd command, whatever the state of crc check option (cmd59).在他的例子中,他发现对于一些 sd 卡,他必须在 sd 命令中放置一个有效的 crc,无论 crc 检查选项(cmd59)的状态如何。 Maybe it is simpler to put a valid crc in all cases.也许在所有情况下都放置一个有效的 crc 更简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM