Question
CubeMx 4.15.1 + STM32L476RC + 1.5.1 + FatFS SD
Posted on July 13, 2016 at 18:24
hello sir.
my project write SD card error, but it read SD card properly. when I debug into code, I found__HAL_SD_SDMMC_GET_FLAG()
in
HAL_SD_WriteBlocks()
function
always get error flagSDMMC_FLAG_DCRCFAIL
. and it write nothing to SD card.I checked my hardware, but it is OK. what wrong with my program? if(NumberOfBlocks > 1){
......}
else { /* Check for error conditions */ errorstate = SD_CmdResp1Error(hsd, SD_CMD_READ_SINGLE_BLOCK); if (errorstate != SD_OK) { return errorstate; } /* In case of single block transfer, no need of stop transfer at all */while(!__HAL_SD_SDMMC_GET_FLAG(hsd, SDMMC_FLAG_RXOVERR | SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_DTIMEOUT | SDMMC_FLAG_DBCKEND))
{ if (__HAL_SD_SDMMC_GET_FLAG(hsd, SDMMC_FLAG_RXFIFOHF)) { /* Read data from SDMMC Rx FIFO */ for (count = 0; count < 8; count++) { *(tempbuff + count) = SDMMC_ReadFIFO(hsd->Instance); } tempbuff += 8; } } }