2018-05-31 05:17 PM
Hi everyone,
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
Reishauer.Ian
in these two threads:https://community.st.com/0D50X00009XkXgUSAV
https://community.st.com/0D50X00009XkXg5SAF
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:
__HAL_SD_CLEAR_FLAG(hsd, SDMMC_STATIC_FLAGS);
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
do{ if (count-- == 0) { return SDMMC_ERROR_TIMEOUT; } }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?
Thanks,
Drew
null2018-08-16 12:41 PM
I don't know.
I've seen issues in various releases when using DMA where code within the stack doesn't wait for read/write completion.
And also when using flow-control.
Secondary issues in POLLED modes is overflow/underflow failure with high bus/interrupt loading, especially problematic with video.
Issues with single sector read/write and use of STOP TRANSFER