VREF for ADC1 not setting on STM32L452
Hi,
I am using an STM32L452 and am trying to set the ADC reference voltage programmatically back and forth between the internal VREF (set to 2.5V) and the external 3V3 power rail. This is specifically for ADC1 channels 1 and channel 7.
I tried a few different ways (both using HAL and also registers/bits) but does not seem to set the VREF as reference voltage to the DAC. The DAC output value still remains the same as if I use the external voltage as reference.
How do I do that? i.e switch the DAC reference voltage back and forth between internal 2.5V and external 3V3 (or internal 3V3 if it is available).
Attached here is the .ioc file and further below is the relevant code.
Also if I try to add the following:
// Enable the clock for the VREFBUF peripheral
__HAL_RCC_VREF_CLK_ENABLE();
like suggested in some examples, it does not recognize that function and there are no .h files already included or part of the HAL header files/library that contain it.
How do I check if VREF clock is enabled?
And if it not, how do I enable it?
// Configure the VREFBUF to 2.5V
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE1);
// Enable the Voltage Reference Buffer (VREFBUF)
HAL_SYSCFG_EnableVREFBUF();
HAL_Delay(100);
/*
* If I uncomment this remains in the while loop
*
// Wait until the Voltage Reference Buffer is ready
while ((VREFBUF->CSR & VREFBUF_CSR_VRR) == 0) {
// Wait until the VRR (Voltage Reference Ready) flag is set
}
*/
// If I uncomment the next line it does not compile
// MX_ADC1_Init();
Thank you as always :)

