Electronic – Vref_cal on STM32F3xx ADC

adccalibrationmicrocontrollerstm32stm32f3

Is there a function to read the Vrefint_cal in Cubes HAL libraries? I'm using the F3xx.
I'd like to measure the supply voltage of the micro. The formula given in the reference manual is:

\$ \Large VDDA = 3.3V \times \frac{Vrefint_{cal}}{Vrefint_{data}} \$

I've been searching through HAL (cube) and couldn't find a method to return the Vrefint_cal. The datasheet says that it is at 0x1FFF F7BA - 0x1FFF F7BB, but I find it silly that there wouldn't be a method to read it directly.

Best Answer

One simple way is the following:

#define VREFINT_CAL_ADDR    0x1FFFF7BA

uint16_t vrefint_cal;                        // VREFINT calibration value
vrefint_cal= *((uint16_t*)VREFINT_CAL_ADDR); // read VREFINT_CAL_ADDR memory location

Or a more general is to simply create a pointer and assign 0x1FFFF7BA to it, and then the rest is the same.