cancel
Showing results for 
Search instead for 
Did you mean: 

DMA not working along with ADC

alien1
Visitor

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. 

4 REPLIES 4
AScha.3
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".
KnarfB
Super User

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

Andrew Neil
Super User

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.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".