cancel
Showing results for 
Search instead for 
Did you mean: 

Using VREFINT on STM32C071K8U6 for battery measurement with variable VDDA

Ricko
Senior III

Hi,

I need to measure a 4.2V battery while my MCU's supply varies between 2.0V and 3.3V. Since VDDA is the ADC reference, raw ADC counts will drift as the supply changes.

And I don't want to use any external references.

My plan:

  1. Feed the battery voltage through a 10K/7K5 divider into one ADC channel (scaled to stay below VDDA_min = 2.0V).
  2. Read VREFINT on a second ADC channel.
  3. Use VREFINT (whose true value is known from the factory calibration in system memory) to back-calculate the actual VDDA, then convert the battery channel's raw count into volts.


The formula being:
V_battery = 3.0 V × (VREFINT_CAL / VREFINT_DATA) × (ADC_battery / 4095) × ((R1 + R2) / R2)

 

Is this the correct approach for getting a supply-independent battery reading on this part?


Anything I'm missing... sampling time for VREFINT, divider impedance vs. ADC sample-and-hold, or calibration register quirks specific to the C0 series?

 

Thank you

0 REPLIES 0