Skip to main content
Visitor II
January 2, 2026
Solved

DMA not working along with ADC

  • January 2, 2026
  • 4 replies
  • 94 views

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. 

    This topic has been closed for replies.
    Best answer by KnarfB

    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

    4 replies

    Super User
    January 2, 2026

    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.

    KnarfBAnswer
    Super User
    January 2, 2026

    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

    Super User
    January 2, 2026

    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.

    Super User
    January 2, 2026

    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.