Skip to main content
Visitor II
March 17, 2022
Question

SD card writing in polling mode without DMA nor FreeRTOS

  • March 17, 2022
  • 1 reply
  • 1214 views

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))

    This topic has been closed for replies.

    1 reply

    Visitor II
    April 5, 2022

    Hello @KhalieAli​ ,

    Welcome to our ST Community :smiling_face_with_smiling_eyes:

    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

    KhalieAliAuthor
    Visitor II
    April 6, 2022

    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

    Visitor II
    April 6, 2022

    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