cancel
Showing results for 
Search instead for 
Did you mean: 

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

Lars Beiderbecke
Senior III
Posted on June 17, 2018 at 12:09

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.

#dma
10 REPLIES 10

I'll have to go dig, probably talking 6-7 years ago, and 2-3 forum transitions. Looking at the Google Drive it was likely a forum attachment, a lot of that stuff got destroyed by ST in the process(es).

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..