cancel
Showing results for 
Search instead for 
Did you mean: 

Sometimes the ADC read ADC1 before ADC0 in Scan Conversion Mode - Why?

DMårt
Lead

I have enable IN1, IN2 and IN5 as ADC inputs. IN1 is called TEMPERATURE. IN2 is called CURRENT and IN5 is called POTENTIOMETER. The DMA is enabled with normal mode and it's called by the Complete Conversion Callback function every time the TIM1 is updated.

DMrt_0-1740612599753.png

 

So, there are also 3 elements in my DMA array. The first element in the DMA array is IN1 and the middle is IN2 and the last one is IN5. In my current situation, IN2 is always zero because there is no voltage at CURRENT (PA1). But sometimes IN1 and IN2 switch position when ADC is sampling data....or DMA switch their place. I don't know. I can see that this occurs sometimes and IN1 gets a zero and IN2 get the same value as IN1 had just before. Thi will occurs once every 15 seconds.

Data:

Processor: STM32F051R8T6

STM32CubeIDE: 1.16.1

Firmware: STM32_Cube_FW_F0 V1.11.5

Question:

How can I take control over the ADC sampling for each element for the DMA? I want to make sure that the ADC scanning the inputs in the correct order and not by free will.

 

 

STM32MP151AAC3 custom board with STM32-OS as operating system: https://github.com/DanielMartensson/STM32-Computer
1 REPLY 1
TDK
Guru

The ADC and DMA don't have the capability to swap values within a series of conversions. Likely there's another bug in the code that explains this.

Are you looking at raw data? or the output of a uart stream? Show what you're seeing.

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