AnsweredAssumed Answered

SDIO timeout in DMA mode

Question asked by Mazzetti.Francesco on Jan 11, 2016
Latest reply on Aug 3, 2017 by Yaroslav Kirillov
In my application (STM32L4) I need to write two file for totally 400kB/s and I can't loss data (from ADC)
In some speed test I obtain about 10MB/s, so theoretically there are no problem (I use a very good uSD with write speed=80MB/s)

The write routine use two big buffer (one for file), every half and full buffer interrupt I write in DMA mode on SD.
The write function of 20kB (I use FATFS) occupy CPU for  1-5ms, but in rare case (probably after error on SD?) this function last 100-200ms and so I loss data becouse the buffer filling is more faster.
I can not afford it

To solve this problem I modify HAL_SD_CheckWriteOperation() that must be call afterHAL_SD_WriteBlocks_DMA()
I changed the default timeout control (there was a terrible decreasing variable) with 35ms on systick. In case of error I return timeout error

Unfortunately FATFS haven't a re-write control after timeout error, so I want to create a trasparent re-write sistem in case of error.
I work in BSP_SD_WriteBlocks_DMA()

I tried to call those functions after a timeout error
-Clear all flag
-Clear all interrupt
But unfortunately not work: the HAL_SD_WriteBlocks_DMA() return CTIMEOUT.
Probably the SD is in error or yet busy?
I hope is possible find a solution

Someone have ideas?
My problem is resolvable?