我在SD Memory Card Specifications没有找到关才CRC的说明,是不是我看得不仔细可否提示一下。 另外好像并不是CRC校验出错,如果CRC校验出错应该返回101,而不是f。SD协议里是这样说的When a flash programming error occurs the card will ignore all further data blocks. In this case no CRC response will be sent to the host and, therefore, there will not be CRC start bit on the bus and the three CRC status bits will read (‘111‘). 只有当发生编程错误,卡才会反回0xff
CRC状态令牌的格式如下: 7 6 5 4 3--------1 0 (bit) x x x 0 CRC Status 1
The meaning of the status bits is defined as follows: ‘010’ - Data accepted. ‘101’ - Data rejected due to a CRC error. ’110’ - Data Rejected due to a Write Error
SPI_SendByte(0xFF); /* 开始发送数据之前发送8个clock clock out 8 clk before start */
if (bmulti == 1) SPI_SendByte(SD_TOK_WRITE_STARTBLOCK_M); /* 写多块开始令牌 start token of write multi blocks */ else SPI_SendByte(SD_TOK_WRITE_STARTBLOCK); /* 写单块开始令牌 start token of write single block */
for (i = 0; i < len; i++) SPI_SendByte(sendbuf); /* 发送数据 send data */