Spark Logic

Measure STM32 VDDA by sampling VREFINT

Estimate the ADC supply on an STM32 without an external voltage divider by measuring the internal reference channel.

Convert the internal reference sample

Use an ADC instance that can sample VREFINT. Enable the internal channel, allow it to stabilize and configure a sample time that satisfies the part's datasheet. With a 12-bit right-aligned ADC, a reading of N represents VREFINT / VREF+ × 4095. If VREF+ is tied to VDDA, estimate the supply with VDDA = VREFINT × 4095 / N.

Where the device provides a factory VREFINT_CAL count, use VDDA = calibration_voltage × VREFINT_CAL / N after putting the measured count in the same resolution as the factory count. Check the datasheet for the calibration voltage and memory address. Skip zero readings to avoid division by zero.

Apply this to an STM32F103 Blue Pill

On the STM32F103C8, VREFINT is ADC1 channel 17 and the internal reference voltage is specified with tolerance. Treat the nominal value as an estimate. For better accuracy, read the count at a known VDDA measured on the board and use that count and voltage as your calibration pair.

The result represents the ADC reference or analog supply. To measure the USB 5 V input or a battery upstream of the regulator, use a correctly scaled divider into an ADC input and convert its result using the estimated reference.

References