Skip to main content
ivan239955_stm1_stmicro_com
Associate III
January 16, 2015
Question

SDIO/FatFS file write in SD Card on STM32F405 fails when ADC interrupt is running [SOLVED]

  • January 16, 2015
  • 4 replies
  • 988 views
Posted on January 16, 2015 at 13:48

Hello,

I have implemented SD Card with FatFS using firstly STCubeMX driver in a polling mode, secondly by adaptation of  the \STM324xG_EVAL\Applications\FatFs\FatFs_uSD example in DMA/Intr mode.

I am writing a line of about 100 characters every 40 ms in the card using f_puts for a long time (using 1-bit access only - another issue sent to the forum).

Unfortunatelly, running an interrupt lasting 1-2 us every 35 us (measured by a scope and yes, I need it seriously) causes that in time of order 1-100 s the function f_puts fails with return code -1.

I tried to increase the stack but it is not the case.

Thank you for any advice.

Ivan

    This topic has been closed for replies.

    4 replies

    ivan239955_stm1_stmicro_com
    Associate III
    January 16, 2015
    Posted on January 16, 2015 at 19:09

    Of course, the ADC interrupt has higher priority (2) in the linear set of them (0-15) than SDIO (5 and 6).

    ivan239955_stm1_stmicro_com
    Associate III
    January 19, 2015
    Posted on January 19, 2015 at 21:29

    I have rearranged the ADC interrupt routine at the expense of main loop so it lasts shorter time: 0.39-1.10 us every 23.5 us, and the file write works O.K. now.

    However, it is problematic if a relatively short interrupt routine spoils SD Card handling.

    ivan239955_stm1_stmicro_com
    Associate III
    January 25, 2015
    Posted on January 25, 2015 at 23:02

    Although the writing to a file did run twice for several hours, now it fails again in several minutes.

    ivan239955_stm1_stmicro_com
    Associate III
    January 27, 2015
    Posted on January 27, 2015 at 10:50

    The problem was that although a code for DMA and interrupt access to SD card was inserted, the polling versions of SDIO read/write functions were called instead of the DMA versions.

    I understand that an interrupt just during trasmition/reception of SD card command/data may corrupt the file write.

    I do not know whether I overlooked a setting in the CubeMX or if CubeMX cannot change the function calls.