2026-05-05 2:38 PM - last edited on 2026-05-08 1:59 AM by mƎALLEm
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.
Is this the correct method?
My plan:
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
Solved! Go to Solution.
2026-05-08 1:51 AM
I haven't used this particular device, but I believe that your method is mostly correct. Reading VREFINT and using that to calculate the actual voltage of other ADC samples seems to be the way to go.
One very minor mistake I can see is that 4095 in your formula should be 4096, as a single ADC count is the reference voltage divided by 4096, not by 4095.
If you haven't already, you may want to read chapter 16.10, "Temperature sensor and internal reference voltage" in the manual, as this explains your exact situation.
Regarding sampling time, with your resistors, I wouldn't go below 350 ns.
2026-05-07 4:38 PM
Hi,
I hope it’s okay to bump this. I’d be grateful if anyone could take a look or share any suggestions. :)
Thank you
2026-05-08 1:51 AM
I haven't used this particular device, but I believe that your method is mostly correct. Reading VREFINT and using that to calculate the actual voltage of other ADC samples seems to be the way to go.
One very minor mistake I can see is that 4095 in your formula should be 4096, as a single ADC count is the reference voltage divided by 4096, not by 4095.
If you haven't already, you may want to read chapter 16.10, "Temperature sensor and internal reference voltage" in the manual, as this explains your exact situation.
Regarding sampling time, with your resistors, I wouldn't go below 350 ns.
2026-05-08 12:19 PM
Thank you @EThom.3