cancel
Showing results for 
Search instead for 
Did you mean: 

ADC results randomly sorted

Chochy
Associate

Hi Iam using STM32F407 discovery board and iam trying to sample 8channels of an ADC. Iam trigerring the ADC with a timer and Iam also using DMA whitch interups the code when the DMA buffer is full. Timer freq is 12kHz. DMA is in circular mode.

Problem is that when I have the sampling time on the channels set to 3cycles, it works fine and the adc channels are aligned correctly in the buffer. But when I increase the cycle duration the chanels get shifted in the buffer so in the first 8 positions of the buffer the 8th channel is not in the 7th place in the array but in 4th. When i set the DMA to normal mode and start the DMA in code the shifting gets randomized everytime the DMA is started. Can someone tell me what the issue is? I ran out of ideas. The values around 2000 are from the 8th channel

Chochy_0-1694615211925.png

This is the result when everything is working.

Chochy_1-1694615224140.png

This is the result when i change the sample time.

Chochy_2-1694615232630.png

And this is a short example of what is happening when i set the DMA mode from circular mode to normal mode.

Chochy_3-1694615313356.png

This line is uncomented when Iam using the DMA in normal mode.
And there is my ADC and DMA settings.

Chochy_4-1694615360855.png

Chochy_6-1694615399164.png

Chochy_8-1694615461882.png

And here is the declaration of the buffer.

 

0 REPLIES 0