Skip to main content
Associate II
September 8, 2026
Question

Should i use single transfer mode instead of double buffer mode in DMA for my program?

  • September 8, 2026
  • 2 replies
  • 25 views

Hello everyone,
Actually I am making a data acquisition system in which my mcu takes analog data from a sensor and stores it in a buffer, and then into a 2nd buffer with the help of DMA in double buffer mode. 
Now i want to transfer this data via UART to my screen with the help of PuTTY with the same ping-pong architecture. For this i need to convert 12 bit adc value to data suitable for uart (8 bit). which i do with the help of a function without any issue and then store them in different two buffers. now the thing is that i want a system in which when buffer 1 is being filled by adc, buffer two will be transferred by uart and vice versa, now the main problem is that there is no sync between the buffers and the ownership. and it is mostly due to the conversion and size of buffers (uart buffers are twice the size of adc buffers) as i am using double buffer transmission mode in DMA controllers of both adc and uart.
So do you think i should use single buffer transmission with circular buffer in DMA or should i continue with my double buffer approach.
Here is my project: Vishwas1523/dataAcquisitionSystem

2 replies

ST Technical Moderator
September 8, 2026

Hello ​@vishwas1523 
After reviewing your project
I would not recommend that you continue with the current approach of using two independent double-buffer DMA engines.

I recommend keeping double-buffer mode on the ADC side, because ADC data comes continuously and the CPU may need time to process or convert the data.

However, on the UART side, I recommend using single transfer mode, mainly because of the difference in data size between ADC and UART.

Your conversion expands each 12-bit ADC sample into 2 bytes. That means when the ADC fills one buffer, the UART needs a larger buffer for the converted data,

so the timing is no longer 1:1.
As a result, the symmetry between the two double-buffer DMA streams is broken.

Until this mismatch is resolved, it is safer to use single mode for UART.

A simple way to avoid this issue is to reduce the ADC resolution to 8 bits or use UART formatting if the data is intended for display in PuTTY.

BR
Gyessine

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
Associate II
September 8, 2026

Thankyou for the reply, 
Your reply gave me some confidence in using single transmission with uart. I will keep this in mind while working on the program and will share the results with you as soon as i get the desirable results :)
Thankyou once again for giving your precious time and actually reading all the messy code of mine. Have a great week ahead!