STM32H7 ADC reading only full scale or very close to full scale: VREFBUF enabling calls by HAL take no effect
CubeMx 5.6.1, STMH7 SW v 1.7.0:
Symptoms: measurements from ADC1/2/3 makes no sense, they are usually very close to full scale or at full scale.
After much onion peeling, it turns out the VREF is not getting enabled.
The CubeMX generated code does try to enable it in stm32h7xx_hal_msp.c:
/** Configure the internal voltage reference buffer voltage scale
*/
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE0);
/** Enable the Internal Voltage Reference buffer
*/
HAL_SYSCFG_EnableVREFBUF();
/** Configure the internal voltage reference buffer high impedance mode
*/
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
But it forgets to enable the VREFBUF clock before doing that.
This seems to be a HAL bug, as I cannot find a "__HAL_RCC_VREF_CLK_ENABLE();" being called before the 3 lines above configuring the VREFBUF.
