Skip to main content
jdo
Associate III
January 13, 2023
Solved

Measure VCC/Battery Voltage Without Using I/O Pin in stm32l010f4

  • January 13, 2023
  • 4 replies
  • 7853 views

I have a circuit with stm32l010f4 that has no ADC pin available because I am using them as digital GPIO, but I need to measure the battery voltage in my application, my question is if Vrefint can be used to make the measurement. I have already made the configuration of Vrefint in stm32cubeide but it only gives me a value of 1.0693W00000Y8BXSQA3.jpg

This topic has been closed for replies.
Best answer by RomainR.

Hello @jdo (Community Member)

Of course, here the project attached.

Best regards,

Romain

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

4 replies

RomainR.
ST Employee
January 13, 2023

Hello @jdo (Community Member)

The internal VREFINT provides an internal stable voltage around 1.22V (see DS12323 Rev 3 table 18)

In your application, if VDDA is same as Battery voltage, you can refer to section "Calculating the actual VDDA voltage using the internal reference voltage" in RM0377 Rev 10 page 311.

You can compute the VDDA voltage using ADC1_IN17 VREFINT Channel.

You will find VREFINT_CAL value address location in DS12323 table 17.

Concerning the VREFINT value = 1 you obtain, I'll check on my side if I can reproduce it.

Best regards,

Romain,

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
RomainR.
ST Employee
January 13, 2023

Here my results. Computation of VDDA using ADC_IN17 VREFINT conversion and internal factory calibration.

Live Expression windows:

adcin17Raw = 1509 VREFINT decimal value converted by ADC.

VDDAmV = 3307 The actual VDDA computed in mV

VREFINTmV = 1220 The actual VREFIN in mV

0693W00000Y8BuHQAV.pngI can share the CubeIDE project, Let me know.

Romain,

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
jdo
jdoAuthor
Associate III
January 16, 2023

hello! i also got adcin17Raw = 1509 VREFINT, i wanted to know what is the formula you use to calculate VDDAmV? i know that in the reference manual there are two formulas. Can you share your code please? i'm also using cubeIde

RomainR.
RomainR.Best answer
ST Employee
January 16, 2023

Hello @jdo (Community Member)

Of course, here the project attached.

Best regards,

Romain

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
jdo
jdoAuthor
Associate III
January 16, 2023

thank you very much it will be very useful

jdo
jdoAuthor
Associate III
January 16, 2023

i test and this is perfect