ADC Calibration - Vdd calculation
ADC reading and voltage level has a direct relationship.


The ADC reading on the VREFINT channel and VDDA have inverse relationship.

An ADC reading is the ratio of the measured voltage to VDDA, scaled up to 4095 (the maximum value that can be expressed on 12 bits). E.g. if you applied VDDA/3 to an ADC input, the result would be 4095/3=1365.

So, the conversion result, ADCx = 4095*VADCINx/VDDA

You cant't measure VDDA directly, because if you apply a voltage equal to VDDA to an ADC channel, the conversion result is always 4095.

VREFINT is a fixed voltage generated inside the MCU, around 1.2 volts. When you convert the VREFINT channel of the ADC, you get the ratio of this voltage to VDDA, i.e. 4095*VREFINT/VDDA. Note that VDDA is now in the denominator. If the supply voltage goes down, the conversion result goes up, and vice versa.

Because VREFINT is not an exact voltage source, they measure it in the manufacturing process, using a good stabilized 3.3V supply, and write the conversion result (VREFINTCAL) in the system memory area.

Now if you'd read the VREFINT channel, and got the exact same value that's stored in the system memory, it would mean that VDDA=3.3V, like in the factory calibration process. This is also what the formula in the question gives you when VREFINTCAL = VREFINTDATA.