cancel
Showing results for 
Search instead for 
Did you mean: 

ADC + DMA circular mode

Posted on April 06, 2016 at 08:38

Hello there,

I am trying to configure ADC and DMA (STM32F4) to work in circullar mode but I fail. There is a lot more conversions than there should be and they are starving other ''processes'' in the mcu.

This is what I am trying to do exacly. TIM8 is running at 20k (PWM, center aligned). An update event of TIM8, should trigger ADC that would measure 8 samples (2 channels, 4 samples per channel, one by one). At the end of those 8 conversions an interrupt should be triggered and this would go on and on after. This is my configuration:

ADC3:

https://pastebin.com/8uNh2TAg

DMA:

https://pastebin.com/F8dXcJMR

I start the DMA with:

retVal += HAL_ADC_Start_DMA(motor->currentLoopAdc,

                (uint32_t*)motor->adcSamples, motor->adcSamplesMax);

adcSamples is an array of 16 elements (int16). adcSamplesMax at this moment is 8, as I want to take 8 measurements. I would apreciate all help!

3 REPLIES 3
Walid FTITI_O
Senior II
Posted on April 06, 2016 at 11:28

Hi Bremen,

Please, try to clarify more your problem/issue.

Have you tried to debug ?

where your code fails exactly ?

Is this an ADC or DMA matter ?

Your code seems to do not configure DMA in case of ADC3 !

-Hannibal-

Posted on April 06, 2016 at 11:49

Yes the matter is only with ADC2 not 3. I mistyped. I did some tests and I found the problem. When I turn ON Circular with DMA, I have to turn off continuous conversions with ADC...

Thank you for answer.
Walid FTITI_O
Senior II
Posted on April 06, 2016 at 13:42

Hi Bremen,

Good. Keep up the good work .

-Hannibal-