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.


2 Answers 2


One simple way is the following:


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.

#define VREFINT_CAL_ADDR ((uint16_t*)((uint32_t)0x1FFFF7BA))

And then, for example:

Vdd = 3300*(*VREFINT_CAL_ADDR)/ADC_raw;

Where Vdd and ADC_raw are uint16_t.

More info here: https://letanphuc.net/2016/07/stm32f0-adc/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.