Skip to main content
Visitor II
March 14, 2024
Question

Issue with read and write SD Card through SPI /(freertos+fatfs)

  • March 14, 2024
  • 2 replies
  • 1230 views

I'm facing an issue with reading and writing data on an SD card using SPI and FATFS on an STM32F767ZIT6 microcontroller. When I don't enable FreeRTOS, the SD card operations work fine. However, when I enable FreeRTOS, the SD card operations fail. During code generation, I receive a suggestion

Dushyantsingh_0-1710452766231.png

 

 I've referred to the following guide for implementing SD card read and write: https://www.micropeta.com/video29

Can anyone provide guidance on resolving this issue?

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    April 18, 2024

    Hello @Dushyantsingh 

    You can refer to the examples provided in STM32Cube firmware H7 located at the following path: Projects\STM32F769I_EVAL\Applications\FatFs\FatFs_uSD_RTOS.

    Also, it is recommended to use DMA process when using FreeRTOS with SD card. 

    Graduate II
    April 18, 2024

    I'd opt for a different socket, WaveShare has several suitable for 3V STM32 operation, and has pull-ups on the correct pins. And supportive of SDIO/SDMMC peripheral usage.

    SD Cards have zero tolerance for you wandering off-task mid way through data interactions.

    Best to use DMA. For F7 use DTCM RAM for DMA buffering with SDMMC, avoids a lot of coherency issues.

    Multiple threads can't use SDIO/SDMMC/SPI and FATFS concurrently. It's a resource that must be serialized / mutex'd