2021-02-03 12:21 PM
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
Solved! Go to Solution.
2021-02-04 09:25 AM
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.
2021-02-03 12:29 PM
What's your ADC reference voltage?
JW
2021-02-03 12:32 PM
it is 3.3v.
2021-02-03 02:41 PM
Did you perhaps set differential mode?
2021-02-03 03:21 PM
I checked the data sheet and RM0454 and I dont see a Differential mode.
I will check the configuration, ADCAL etc.
2021-02-04 09:25 AM
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.
2021-02-04 01:12 PM
Thanks for coming back with the solution. Please select your post as Best so that the thread is marked as solved.
JW