cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with SDMMC driver and STM32F7

Andrew Messier
Associate II
Posted on June 01, 2018 at 02:17

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

null
10 REPLIES 10

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..