AnsweredAssumed Answered

STM32Cube_FW_F4_V1.19.0 + FREERTOS + FATFS + SDIO + DMA

Question asked by Mario Gkiolena on Feb 11, 2018
Latest reply on Feb 18, 2018 by Mario Gkiolena

Hello,

I am using a custom board with an STM32F401RB microcontroller that I want to be able to save data to SD Card. At first I tried without using FreeRTOS and I found that writing data every 20ms is not applicable because every writing cycle sometimes took about 150ms and from specifications can take up to 250ms. So I thought to give a try on FreeRTOS (it is my first time with FreeRTOS and I am currently reading the documentations). I made a basic cube project just for the SD Card with slow SDIO speed (1MHz) that I have posted here. I run the code above to test if the SDIO and FatFS driver works but keeps failing. Am I missing something?

 

/* StartDefaultTask function */

void StartDefaultTask(void const * argument)
{
/* init code for FATFS */
MX_FATFS_Init();

/* USER CODE BEGIN 5 */
FATFS fs;
FIL fil;
FRESULT res;
char mybuff[64];

/* Infinite loop */
for(;;)
{
res = f_mount(&fs, "", 1);
if (res){
sprintf(mybuff, "failed, %u", res);
}

/* Create a file as new */
res = f_open(&fil, "speed.txt", FA_OPEN_ALWAYS | FA_WRITE);
if (res){
sprintf(mybuff, "failed, %u", res);
}
/* Close the file */
res = f_close(&fil);
if (res){
sprintf(mybuff, "failed, %u", res);
}
osDelay(1000);
}
/* USER CODE END 5 */
}

Attachments

Outcomes