cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 RTOS SDCard doesn`t work

lorant124
Associate III

Hi, I have custom HW with STM32L496RGTx. On board I have SD card slot.

I tried HW with CubeMX. Setted SDMMC1 to Mode: SD 1, SD DMA - SDMMC1 and divider to 24. In code I wroted:

FATFS SDFatFs;  /* File system object for SD card logical drive */
char SDPath[4]; /* SD card logical drive path */
FIL Test_File; /* File object */
char SD_File_name[22];
uint8_t res = 0;
...
 
void main(void) {
...
res = f_mount(&SDFatFs, (TCHAR const*)SDPath, 0);
sprintf(SD_File_name, "Test.txt");
res = f_open(&Test_File, SD_File_name, FA_WRITE | FA_CREATE_ALWAYS);

It is work good.

But if I enable FreeRTOS CMSIS V2, function f_open(...) always return

FR_NOT_READY,	/* (3) The physical drive cannot work */

I use CubeMX 6.1.1 and STM32L4 v1.16.0 package.

Please help what am I doing wrong.

Thank you

1 REPLY 1

Hello,

A divider of 24 is not a good idea, Freq requirement is <=24 MHZ for this device and the ideal=max=24MHZ. 24=SDMMC_CKLK / divider or divider=SDMMC_CLK/24

To use DMA template in LWIP (diskio.c) requires the SDMMC peripheral to have the DMA already enabled.