AnsweredAssumed Answered

Best practice using DMA to read from UART and write to SD?

Question asked by Lars Beiderbecke on Jun 17, 2018
Latest reply on Jun 18, 2018 by Tilen MAJERLE

I'm reading data from a UART with DMA and want to write that data to an SD card (on a F722). Since the data is much longer than my buffer, I chose circular buffer for the DMA.


The problem now is that I need to save the receive buffer to SD occasionally, but how do I know when I need to do this?


Can someone recommend the best approach here, using Cube HAL:


  • Should I chop my Receive_DMA() into smaller chunks of buffer size, and receive them individually?  (I may loose data.)
  • Should I count the number of received bytes (how?) and save the buffer if some threshold is reached?
  • Can I enable direct UART-to-SDMMC DMA?  (I don't even know what that means: Does the data go into an open file, and how can I remove the length header of the data first?)


I'd really appreciate some ideas. The Cube examples are way too simple.