2015-05-26 12:06 PM
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! Charles2016-02-04 07:02 AM
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)