cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO timeout in DMA mode

fra
Associate II
Posted on January 11, 2016 at 01:02

Hi

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

-HAL_SD_StopTransfer()

 

-Clear all flag

 

-Clear all interrupt

 

-SD_DMA_Congif()

 

-HAL_SD_WriteBlocks_DMA()

 

-HAL_SD_CheckWriteOperation()

 

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?

thanks

#dma #sdio #timeout
2 REPLIES 2
stm322399
Senior
Posted on January 16, 2016 at 21:07

Unfortunately, the write command sent to SDCard last 1-5ms and sometime up to 250ms. That's the way SDCard are working and it is clearly stated in the SD specification.

To circumvent that behavior, you have almost no other choice than buffering your writes, while the SDCard is busy.

Yaroslav Kirillov
Associate II
Posted on August 03, 2017 at 13:04

Hi Cesco.

Can you help me with the working code for the DMA read/write to SD card.

I have the same problem. Cannot find any solution till now for the write multiple blocks in DMA mode.

Thank you.