Author Topic: STM32C071K8U6 for battery measurement with variable VDDA  (Read 485 times)

0 Members and 1 Guest are viewing this topic.

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1233
  • Country: fr
STM32C071K8U6 for battery measurement with variable VDDA
« on: May 06, 2026, 05:05:48 pm »
Hi,
I am using an STM32C071K8U6 and 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 approach for getting a supply-independent battery reading?

My plan is to:
- Feed the battery voltage through a 10K/7K5 divider into one ADC channel (scaled to stay below VDDA_min = 2.0V).
- Read VREFINT on a second ADC channel.
- 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.

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

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
« Last Edit: May 06, 2026, 09:34:16 pm by ricko_uk »
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 3813
  • Country: gb
Re: STM32C071K8U6 for battery measurement with variable VDDA
« Reply #1 on: May 06, 2026, 06:16:49 pm »
At a glance it sounds sensible, but I have no knowledge of C series. You say the mcu supply varies, but could you simply things by only doing battery voltage measurement when, say, running at 3V3. Do you drop to 2V0 to minimise power consumption? If yes, you maybe want to switch off VREFINT and use a fet to switch off the battery voltage divider, to save power.

Also, I would add 100nF at the voltage divider output to lower impedance seen by adc input.
« Last Edit: May 06, 2026, 06:23:51 pm by voltsandjolts »
 
The following users thanked this post: ricko_uk

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1233
  • Country: fr
Re: STM32C071K8U6 for battery measurement with variable VDDA
« Reply #2 on: May 07, 2026, 11:43:39 pm »
Thank you @voltsandjolts

Sorry, I didn't explain myself correctly. The MCU voltage varies because the battery discharges and pushed the LDO down.

I do have a cap at the divider output, and also have connected the bottom of the divider to a micro's pin so it drain current only when set to output and 0V (during a measurement).

 

Offline hoppppla

  • Newbie
  • Posts: 7
  • Country: de
Re: STM32C071K8U6 for battery measurement with variable VDDA
« Reply #3 on: May 08, 2026, 10:14:55 am »
Hi ricko,

have a look to the refman https://www.st.com/resource/en/reference_manual/rm0490-stm32c0-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf, Chapter 16.10 Temperature sensor and internal reference voltage.
There is a paragraf "Calculating the actual VREF+ voltage using the internal reference voltage" with all the formulars you need.

best regards
 

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1233
  • Country: fr
Re: STM32C071K8U6 for battery measurement with variable VDDA
« Reply #4 on: May 08, 2026, 07:16:44 pm »
Thank you @hoppppla very useful!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->