2026-01-02 3:24 AM
Tried running DMA with ADC simultaneously by configuring both in CubeMX, but I am not getting correct ADC values in the buffer. The sin wave from the signal generator is completely distorted. The ADC works individually without the DMA by filling the buffer through interrupts. The DMA is configured in circular mode. I even tried running the sample code of ADCgainCompensation from ST(modified a little to get values in a buffer), but had no success.
2026-01-02 3:55 AM
Hi,
>ADC works individually without the DMA by filling the buffer through interrupts
Why this ? The way with DMA is: read ADC with DMA to circular buffer; only DMA needs INT, to do the half/full callbacks, so you know, a buffer is filled with new data.
2026-01-02 4:22 AM
If you want to capture a signal at regular time intervals, the most common approach is a timer driven ADC with circular DMA output. Check out the ADC_SingleConversion_TriggerTimer_DMA examples which are avail. in CubeMX Example Selector, but unfortunately not directly for G4.
hth
KnarfB
2026-01-02 5:08 AM
Welcome to the forum.
Please see How to write your question to maximize your chances to find a solution for best results.
In particular, please give details of your hardware setup, software tools, etc.
@alien1 wrote:I am not getting correct ADC values in the buffer.
How, exactly, do you determine that?
How do they differ from what you expect to be "correct"?
@alien1 wrote:The sin wave from the signal generator is completely distorted.
What do you mean by that? Is this "signal generator" the input to the ADC ?
Do you mean your STM32 is causing the "signal generator" to distort?
Show both the input and output waveforms.
2026-01-02 6:34 AM
What values do you get? What values do you expect instead?
Note that the input range for both sides of the DC must be between 0V and VDD, even in differential mode.