cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX & STM32L4 Library 1.12.0 ADC Problem

Rob.Riggs
Senior

Is there a known problem with HAL ADC driver in the 1.12.0 L4 HAL library?

I have working code using STM32L4 HAL 1.8.1 that I recently upgraded to latest Cube & HAL (4.26.1 & 1.12.0 respectively) and I have very odd behavior with the ADC after the update. The project is using a Nucleo32-L432KC board. The problem is that with this HAL version, the ADC reads very high values (close to VREF/2) when connected directly to ground.

To ensure that this was not due to a failure of the Nucleo board, I reused one of my Mbed projects that writes the ADC value converted to voltage to a SPI LCD. That worked as expected, with VSS and VDD measuring near min and max values respectively.

To ensure that this was not an issue with a bad upgrade, I created a new CubeMX project that does nothing but poll the ADC and write the value out to the UART. It shows the same misbehavior. GND shows values around 2000 and VREF shows close to the expected value.

To verify that this was a HAL issue, I replaced the files that STM32CubeMX placed under Drivers/STM32L4xx_HAL_Driver in that new project with those from STM32Cube_FW_L4_V1.8.1/Drivers/STM32L4xx_HAL_Driver and verified the the code behaved as expected. It does. Connnecting the ADC to VSSA and VDDA return the expected min and max values.

Is this a known problem with this HAL version? If so, when will a fix be available?

If you need me to post code that exposes the problem, please ask.

1 REPLY 1
Rob.Riggs
Senior

Looks like I'm running into this: https://community.st.com/s/question/0D50X00009bLP0eSAG/adc-init-bug-with-optimization-o1-stm32l4 (undefined behavior due to bogus shift operation).