cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476VG - RTC - Vbat

mejrissi
Associate II
Posted on September 14, 2016 at 19:08

Dear Gents,

I am using a STM32L476VG for my application. The RTC can be powered by Vbat provided by an external battery in case that VDD drops off. In this mode, when the MCU is powered by Vbat, only the RTC works, keeping track of time. Is there any way to detect if Vbat is going to drop under the needed voltage with the RTC?

#rtc #stm32l4 #time
6 REPLIES 6
jpeacock23
Associate III
Posted on September 14, 2016 at 19:36

Check the reference manual section on the A/D converter.  There is an internal ADC channel connected to VBAT through a 1/3 divider (VBAT may be higher than VREF).  You can sample the pin voltage to determine the state of the battery.  If you use the internal VBAT charger make sure it's off.

  Jack Peacock

Walid FTITI_O
Senior II
Posted on September 15, 2016 at 13:28

Hi mejrissi.chiheb,

As mentioned in the STM32L4x6 reference manual, in page 500, part “16.3.32 Vbat supply monitoring�:

The VBAT monitoring channel (VBAT/3) is connected to ADC1_IN18 and ADC3_IN18. The CH18_SEL bit bit in the ADCx_CCR must be set to enable the conversion of internal channels ADC1_IN18 and ADC3_IN18 (VBAT/3). Th measured value is  Vbat/3

-Hannibal-

mejrissi
Associate II
Posted on September 15, 2016 at 16:30

Hannibal, Jack,

Thank you very much for your answer. Only the RTC is working when the MCU is on VBat, so I can't use the ADC registers. Is there another way to do this?

Walid FTITI_O
Senior II
Posted on September 16, 2016 at 17:32

Hi mejrissi.chiheb, 

When you want to check the Vbat volatege or there is a drop, you should this measuring or monitoring of voltage in Run mode

-Hannibal-

GUIRAT.Youssef
Associate III
Posted on November 21, 2016 at 18:12

Hi,

I'm working on a project using the STM32L476RG microcontroller with IAR IDE . In my project , I shall use the RTC peripheral in order to get accurate time value.

Here I have two questions to ask :

1- If the voltage that supplies the RTC goes down ( run out of battery for example ) and then we power on the RTC , the time value that we get is re-initialized from zero ? Or we get the last time value from where we did stop ?

2- When I leave my board running for too long ( 24hours for example ) and after that I went to check the RTC time value I find a gap of 10seconds between my desktop time and the RTC time . 

So, the question here , why I do get this gap ? I shall not forget to mention that I have modified values of these parameters ( RTC_ASYNCH_PREDIV and RTC_SYNCH_PREDIV ) in order to remove the gap but in vain.

can someone clarify these issues for me , maybe I'm missing something.

Thanks

Posted on November 22, 2016 at 07:53

Please don't hijack threads, start your own.

JW