cancel
Showing results for 
Search instead for 
Did you mean: 

Reading a battery voltage on STM8S003F3

cfleck
Associate II
Posted on May 26, 2015 at 21:06

Hey guys,

I currently have an STM8S003F3 that is being powered by a battery. I want to be able to read the battery voltage, but am trying to reserve pins. I am trying to read the battery voltage off the Vdd pin and compare it to the internal voltage of the STM8S. I am having trouble finding the documentation that describes which internal ADC channels are connected to the Vdd pin, or how to set an ADC up to read the Vdd pin. Does anyone know where this documentation is or how this can be done?

Thank you!

Charles
1 REPLY 1
paulrbryson
Associate III
Posted on February 04, 2016 at 16:02

That part the does not have an internal reference.  The Vdd pin is used as the reference for the ADC.  So reading the Vdd voltage will ALWAYS return 0x3ff from the ADC whether you use an internal connection (that may not be possible) or a separate pin.  

If you want to read the battery voltage you will have to provide an external voltage reference on on ADC pin.  By reading the reference voltage you can infer the Vdd voltage.  

Vdd =  ((reference voltage)*1024)/ (adc reading)