/* MSD chip select low */ MSD_CS_LOW(); /* Send CMD17 (MSD_READ_SINGLE_BLOCK) to read one block */ MSD_SendCmd(MSD_READ_SINGLE_BLOCK, ReadAddr, 0xFF);
/* Check if the MSD acknowledged the read block command: R1 response (0x00: no errors) */ if (!MSD_GetResponse(MSD_RESPONSE_NO_ERROR)) { /* Now look for the data token to signify the start of the data */ if (!MSD_GetResponse(MSD_START_DATA_SINGLE_BLOCK_READ)) { /* Read the MSD block data : read NumByteToRead data */ for (i = 0; i < NumByteToRead; i++) { /* Save the received data */ *pBuffer = MSD_ReadByte(); /* Point to the next location where the byte read will be saved */ pBuffer++; } /* Get CRC bytes (not really needed by us, but required by MSD) */ MSD_ReadByte(); MSD_ReadByte(); /* Set response value to success */ rvalue = MSD_RESPONSE_NO_ERROR; } }
/* MSD chip select high */ MSD_CS_HIGH(); /* Send dummy byte: 8 Clock pulses of delay */ MSD_WriteByte(DUMMY); /* Returns the reponse */ return rvalue; } 其中有一句if (!MSD_GetResponse(MSD_START_DATA_SINGLE_BLOCK_READ))为什么不成立
程序不全兼容MMC,SD1.0,SD2.0或者是SD2.0大容量卡,如果只是 if (!MSD_GetResponse(MSD_START_DATA_SINGLE_BLOCK_READ))不成立,尝试多发几次读命令,反复判断MSD_GetResponse(MSD_START_DATA_SINGLE_BLOCK_READ)的值,个人觉得这个sd卡程序还是得重写,我这写了一下,已调试通过。大家有兴趣的可以一起讨论。jynkelan@yahoo.com.cn