Skip to main content
MEder
Associate III
February 3, 2021
Solved

STM32G070RB Vbat Data sheet error

  • February 3, 2021
  • 6 replies
  • 1764 views

According to the data sheet, sec 3.13.3 says the VBAT voltage is measure by the ADC as VBAT/3, or one third Vbat.

using :

uint64_t volt = (uint64_t)(((uint64_t)3300U*adc_result)/(uint64_t)4095U);

I get 2/3 Vbat

Changing to uint64_t volt = (uint64_t)(((uint64_t)4950U*adc_result)/(uint64_t)4095U);

I logged the following

Vin Measured

0.500 684 (seems to be the lowest it goes)

1.000 997

1.500 1496

2.000 1999

2.500 2496

3.000 2992

3.500 3.492

Then in RM0454, 14.3.6 VBat/3, and 14.10 Digital value is half the Vbat voltage. While Showing Vbat/3.

But I clearly see Vbat *2/3 from the ADC. Data sheet error?

Thanks

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

Found the Issue, I set the OVSE bit in the CFGR2 , instead of the CKMODE bits. So it was performing a left shift in the DR reg, doubling the value.

Now I get the Proper 1/3 Vbat voltage.

Thanks for the help.

6 replies

waclawek.jan
Super User
February 3, 2021

What's your ADC reference voltage?

JW

MEder
MEderAuthor
Associate III
February 3, 2021

it is 3.3v.

Uwe Bonnes
Chief
February 3, 2021

Did you perhaps set differential mode?

MEder
MEderAuthor
Associate III
February 3, 2021

I checked the data sheet and RM0454 and I dont see a Differential mode.

I will check the configuration, ADCAL etc.

MEder
MEderAuthorBest answer
Associate III
February 4, 2021

Found the Issue, I set the OVSE bit in the CFGR2 , instead of the CKMODE bits. So it was performing a left shift in the DR reg, doubling the value.

Now I get the Proper 1/3 Vbat voltage.

Thanks for the help.

waclawek.jan
Super User
February 4, 2021

Thanks for coming back with the solution. Please select your post as Best so that the thread is marked as solved.

JW