cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Does not work properly

Hesseltjuuh
Associate III

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:

Hesseltjuuh_0-1705059418546.png

Hesseltjuuh_1-1705059430206.png

 

And here is the code with the returned values:

Hesseltjuuh_3-1705059628054.png

 

Hesseltjuuh_2-1705059475003.png

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Chief II

... and for Vbat :

from rm:

AScha3_0-1705061605477.png

So if Vdda is 3,3V , Vbat  932 * (3,3 V / 4095 ) * 4 = 3,001 V .

 

.. but for Vrefint :

AScha3_1-1705062500861.png

 

AScha3_0-1705062380905.png

-> set this TSVREFE first !

Then test Vrefint again...  (should show about 1485  */- 40 )

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

3 REPLIES 3
Sebastiaan
Senior

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).

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

Hesseltjuuh_0-1705061379144.png

 

AScha.3
Chief II

... and for Vbat :

from rm:

AScha3_0-1705061605477.png

So if Vdda is 3,3V , Vbat  932 * (3,3 V / 4095 ) * 4 = 3,001 V .

 

.. but for Vrefint :

AScha3_1-1705062500861.png

 

AScha3_0-1705062380905.png

-> set this TSVREFE first !

Then test Vrefint again...  (should show about 1485  */- 40 )

If you feel a post has answered your question, please click "Accept as Solution".