2024-01-12 03:40 AM
Hello,
I'm trying to use the ADC to measure the Vbat voltage on my STM32F401RCT6 but i get some strange values. Here is my setup in the device configuration tool:
And here is the code with the returned values:
Vref_Val = 303
Vbat_Val = 932
I have connected a CR1220 battery, but the Vref value seems to be really small for a 12 bits ADC value. I'm pretty new to STM so if anyone could help me thats would be great.
Thanks!
Solved! Go to Solution.
2024-01-12 04:19 AM - edited 2024-01-12 04:45 AM
... and for Vbat :
from rm:
So if Vdda is 3,3V , Vbat 932 * (3,3 V / 4095 ) * 4 = 3,001 V .
.. but for Vrefint :
-> set this TSVREFE first !
Then test Vrefint again... (should show about 1485 */- 40 )
2024-01-12 03:58 AM
How much is VBAT? for example, 3.7V? In that case VREF_INT would be 3.7 / 932 * 303 = 1,202V, which is very close to the values of the datasheet.
However, that seems a bit strange because it would imply a VREF+ way larger than 3.3V (since VBAT is only 932 from the maximum value of 4095).
So the ratio of vbat versus vref_int seems to match, but the absolute values seem to be wrong. Is that in line with your thoughts? Not sure what could be the root cause of this... A voltage divider, but since vref_int is internal, that should not matter (there's no internal voltage divider as far as I know).
2024-01-12 04:10 AM
I just measured Vbat and its 3V hooked up to the STM32. But yeah you've explained it way better than me. I have this ferrite bead hooked up to the Vref+ pin. Might that be a problem? I dont think so since it has a resistance of 120 Ohm @ 100MHz
2024-01-12 04:19 AM - edited 2024-01-12 04:45 AM
... and for Vbat :
from rm:
So if Vdda is 3,3V , Vbat 932 * (3,3 V / 4095 ) * 4 = 3,001 V .
.. but for Vrefint :
-> set this TSVREFE first !
Then test Vrefint again... (should show about 1485 */- 40 )