2019-01-16 02:54 AM
I use the Vbat pin to measure a lithium battery (3.6V) at a STM32L471 (Vcc=1.8V Vdda=3V).
However my measurements are off by ~0.15V even though I confirmed the physical signals.
Do I have to calibrate the ADC somehow for this to work properly?
Expected 2.999V -> measured 2.882V
Expected 3.268V -> measured 3.100V
Expected 3.567V -> measured 3.405V
2019-01-16 04:01 AM
> Do I have to calibrate the ADC somehow for this to work properly?
At least perform calibration as per Calibration (ADCAL, ADCALDIF, ADCx_CALFACT) sub chapter in RM.
JW
2019-01-16 05:47 AM
Remember the ADC is ratiometric. Your samples are not absolutes but a percentage of the reference voltage on the Vref pin. From the example you show it appears the error decreases as battery voltage drops. Do you use a constant voltage reference for Vref, connect to Vdd, or something else?
It may be the problem is in the stability of your reference, not the ADC. You can test this by sampling the Vrefint internal bandgap reference. If you see this voltage also varying (it should be very close to data sheet value regardless of Vdd and Vdda) it's definitely a problem with Vref. When you sample the bandgap reference you are essentially testing the ADC positive reference.
Jack Peacock