cancel
Showing results for 
Search instead for 
Did you mean: 

SD card writing in polling mode without DMA nor FreeRTOS

KhalieAli
Associate

I am trying to write in the SD card in polling mode and it works successfully first two time and when i try to open the same file and write to it is fails and stuck at function " HAL_SD_ReadBlocks " at file stm32h7xx_hal_sd.c at the following condition:

if(((HAL_GetTick()-tickstart) >= Timeout) || (Timeout == 0U))

3 REPLIES 3

Hello @KhalieAli​ ,

Welcome to our ST Community 😊

In order to allow a better analysis of your problem, could you please share the project file to reproduce this issue, so that we can give you an answer.

Thanks in advance.

BeST Regards,

Walid

Hello @Walid ZRELLI​ 

using generated APIs at "sdmmc.h" and "fatfs.h" i call MX_SDMMC1_SD_Init(); MX_FATFS_Init(); in the initialization

  • then at run time i made the following code in polling mode and i am not using DMA

if(f_mount(&FatFsSystem, (TCHAR const *)SYSTEM_PARTITION, 0) == FR_OK)

{

// Open file HelloWorld

if(f_open(&elffile, "LogFile.txt", (FA_CREATE_ALWAYS | FA_WRITE )) == FR_OK)

{

char myData[] = "Hello Bent, It is Workking now \nthanks, it is me khalid";

f_puts(myData,&elffile);

f_close(&elffile);

}

}

it success first time but when i call this code at the second time it stuck waiting time out which is very large number and when i decreased it the SD card read write operation never worked

thanks in advance

Hello @KhalieAli​ ,

You can refer to the following example provided in the H7 firmware package:

  • Projects\STM32H743I-EVAL\Applications\FatFs\FatFs_uSD_Standalone

This may help you.

BeST Regards,

Walid