I'm using an STM32F777 part, with files generated by the very latest version of CubeMX (4.25.1)
I've spent the day struggling through issues writing a file to an SD card using the fatfs middleware. I've pretty much followed the path of issues experienced by piet t in these two threads:
So far, I've had to add pull-up resistors in the CubeMX configuration for the CMD and data lines (which I understand shouldn't be strictly necessary) and applied these two fixes:
1. Initialized "ReadStatus" and "WriteStatus" to '1' in the respective SD_read and SD_write functions in sd_diskio.c
2. Reset the state of the peripheral after the ReadBlocksDMA and WriteBlocksDMA with these lines:
hsd->State = HAL_SD_STATE_READY;
both of which were discovered and reported in the threads linked above.
Now my code succeeds occasionally (30%-ish?), but when it fails it spins in the following loop in SDMMC_GetCmdResp1
if (count-- == 0)
}while(!__SDMMC_GET_FLAG(SDMMCx, SDMMC_FLAG_CCRCFAIL | SDMMC_FLAG_CMDREND | SDMMC_FLAG_CTIMEOUT));
Has anyone come across this or have a clue what might be wrong?