cancel
Showing results for 
Search instead for 
Did you mean: 

ADC DMA interrupt triggers very slowly when the ADC conversion is triggered by a timer

hesam moshiri
Associate III
Posted on July 09, 2018 at 14:24

Hi,

The MCU is STM32F4

I put the Timer2 (60MHz clock) to trigger every 100mS. it means it triggers its interrupt and ADC every 100mS. Below is the configuration of the ADC and Timer2.

I checked the TIM2 interrupt by a GPIO toggle and it gets fired every 100mS or 50Hz which is correct.

BUT the ADC DMA gets fired almost 2 times per second, it means 2Hz!!!

.

it is weird because I just put 100 for the buffer and whole sampling to fire the ADC DMA interrupt must not take more than 100 * 0.5uS = 50uS , because each ADC channel can handle the speed of 2Msps. This ADC sampling speed is achivable and I tested it, if the ADC works in the continuous conversion mode, but I could not achieve this when I trigger it externally.

The triggering is much slower than the ADC and this should not make any timing conflicts, it means the whole ADC conversion finishes much sooner (50uS) before the next trigger comes in

0690X00000604lFQAQ.jpg

0690X00000604V3QAI.jpg

5 REPLIES 5
AvaTar
Lead
Posted on July 09, 2018 at 15:41

I do not see any DMA configuration.

I don't do any Cube, BTW.

Size and number of words transferred by DMA must match your number (and size) of ADC channels per sequence, else DMA TC interrupts get out of sync.

Posted on July 09, 2018 at 15:46

What are you clocking the F4 at? Right now triggering at TIMCLK/600000

Yeah, does sound weird, can't really help you with CubeMX issues.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 09, 2018 at 16:25

as I mentioned it is 100 buffer size. therefore it will take around 50uS (100 * 0.5uS)  which I have confirmed it when I don't use ADC trigger, but continues sampling. it means if I don't use triggering and just make continues conversion, the ADC DMA interrupt will get fired every 50uS (end of conversion)

Posted on July 09, 2018 at 16:26

Timer clock is 60MHz and I customized the TIM2 to fire the interrupt at 100Hz rate. Which must be the same as triggering the ADC.

0690X00000604iqQAA.jpg
hesam moshiri
Associate III
Posted on July 11, 2018 at 20:33

Actually the ADC Interrupt routine (ADC_IRQHandler) gets fired on 100Hz frequency which is correct and it is in harmony with Timer triggering, but the DMA interrupt fires much slower, once per second.

I read the data by the ADC interrupt, but when the DMA fires, it shows a 1 second glitch.

the only time that this does not happen is when everything set on the continues mode. in that case we are facing with a different project because then ADC, and specifically DMA works on its own continuously and triggering does not matter then. it is like the constant ADC reading. in this case the ADC interrupt gets fired at about 120Hz.