2016-01-10 04:02 PM
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 itTo 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 errorUnfortunately 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 solutionSomeone have ideas?My problem is resolvable?thanks #dma #sdio #timeout
2016-01-16 12:07 PM
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.2017-08-03 04:04 AM
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.