2023-09-13 07:31 AM
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
This is the result when everything is working.
This is the result when i change the sample time.
And this is a short example of what is happening when i set the DMA mode from circular mode to normal mode.
This line is uncomented when Iam using the DMA in normal mode.
And there is my ADC and DMA settings.
And here is the declaration of the buffer.