Showing results for 
Search instead for 
Did you mean: 

ADC Rank starts at 2 on 1st conversion



STM32CubeIDE: Version: 1.14.1 Build: 20064_20240111_1413 (UTC)

TM32CubeMX: Version: 6.10.0-RC9 Build: 20231120-2037 (UTC)



Linux Lmint21





I set up ADC3 in CubeMx to enable scan on Internal Temperature and VBat and set the DMA to DMA1 in Circular mode, Half-Word and set the conversion mode to Regular, Launched by software . In a thread for ADC processing I start the ADC process by calling HAL_ADC_Start_DMA() then drop into a loop that waits for a semaphore to know when the conversion is complete. When the conversion is complete, the ADC thread collects and processes the data from the structure where the DMA put it. Then, after a delay, the ADC is started again using HAL_ADC_Start_DMA().


The first conversion results in the values swapped where VBat contains the temperature and temperature contains the VBat value. All subsequent conversion have the order correct.


I have tried changing the buffer size and using alignment directives but the problem persists. Obviously, I could simply ignore the first conversion, but I would like to understand why the first conversion is out of order. I also tried setting the scan count to more than two values, but that still have the first conversion order starting at Rank 2. It is interesting to note that at the end of the conversion sequence Rank 1 is always present at the end of the buffer and at the end of the 2nd time through the scan Rank 1 is at the beginning.