Does anyone know if there is a way to check if there is a voltage on the RTC?
Right now I’m seeing devices with a coin cell battery installed for the RTC but there is some flux between the battery and the RTC. This makes the device not maintain the RTC. To check it requires disassembly.
on page 16.
Many ST serial real-time clocks include a battery monitor function which sets the BL bit
when the battery is low. The basic functionality is to periodically compare the battery to the
internal 2.5 V reference and set the BL bit whenever the battery voltage is less than 2.5 V.
It doesn’t really need to be a spare pin. It can actually be almost any A pin. The only constraint is that it can’t be a pin that’s a 5V input, and it can’t be the pin you plan to analogRead() from right after you read the battery (or temperature).
In other words, it can be WKP (A7) if you’re using it for waking up or GPIO (as long as you’re not using it as a 5V tolerant input).
Or any A pin you’re using as a GPIO input (as long as you’re not feeding it 5V). This also includes P1S0-P1S3 on the P1.
It can also be any A pin you use as a GPIO output. In retrospect, that probably won’t work quite right.
It can be an analog input you are using in your own code… however you need to read any other pin first. So say you read A1 and A2 in your app. You can pass A2 as long as you always read A1 first. It’s working around an annoying thing in system firmware where if you read the same pin you last read the ADC is not completely reset and you’ll get wrong readings.
(I can’t save and restore the settings, because there’s no way to read them out first.)
@rickkas7 do you think reading the bvat can drain the battery?
Over the coarse of 11 hours of reading the bvat every 400ms the battery voltage has dropped from 3.05 to 2.98.
EDIT: It looks like enabling the ADC does cause power consumption of the battery. Is there a way to turn off the bridge divider once turned on?
From:
3.1.2 Special firmware configuration
ADC application
● The ADC can be also a source of current draw during the Stop mode, unless it is
disabled before entering it. To disable it, write the ADON bit in the ADC_CR2 register to
0.
● In run mode, ADC can be configured in power-down mode by clearing the ADON bit. In
this mode the ADC consumes almost no power (only a few µA).
● In the application controlling the battery threshold through ADC_IN18 input channel,
when setting VBATE bit in ADC_CCR register in run mode, there is an extra current
consumption seen in Vbat pin. As a consequence, this may impact the battery life time.
In fact, as the VBAT voltage could be higher than VDDA, to ensure the correct
operation of the ADC, the VBAT pin is internally connected to a bridge divider by 2. This
bridge is automatically enabled when VBATE is set, to connect VBAT/2 to the
ADC1_IN18 input channel. To prevent any unwanted consumption on the battery, we
recommend enabling the bridge divider only when needed, for ADC conversion.
I updated the photon-vbat library to only turn on vbat detection right before reading then turn it off after. This should eliminate the battery drain issue.