cancel
Showing results for 
Search instead for 
Did you mean: 

Use of RTC in back up domain

rohitpai77
Associate II
Posted on April 09, 2014 at 11:33

Hello All,

I have read from STM324xx data sheet that the RTC is registers are still valid and running when Vdd is off and Vbat is present. I am not sure how the microcontroller manges normal running mode and standby mode (Vdd is off and Vbat is present). 

I have two questions

1. Is it responsibility of FW to manage the switch or is is managed by the MCU hardware.? When Vdd is off and Vbat is present does the microcontroller automatically goes to standby mode..? Do we need any kind of configuration for this...?

2. How to know after power start whether the product up from a stand by mode or a power down reset. 

Thnaks for any kind of suggestion.

BR,

Rohit 

#rtc #rtc #rtc #stm32 #stm32
12 REPLIES 12
chen
Associate II
Posted on April 09, 2014 at 12:05

Hi

''1. Is it responsibility of FW to manage the switch or is is managed by the MCU hardware.? When Vdd is off and Vbat is present does the microcontroller automatically goes to standby mode..? Do we need any kind of configuration for this...?''

It is the HW that manages the switch from RTC/SRAM powered to not powered.

It is the firmwares responsibility to make sure the RTC is setup/configured correctly.

No, when Vdd is not present - the processor is OFF

''2. How to know after power start whether the product up from a stand by mode or a power down reset. ''

    uint32_t lastRstState = RCC->CSR;

    // code to detect a warm reboot

    if ( RCC_CSR_SFTRSTF & lastRstState )

    {

        uartPrintf(''\n\r Warm boot (reset caused by software)'' );

    }

    else

    {

        uartPrintf(''\n\r Cold boot (Powered from Off)'' );

    }

rohitpai77
Associate II
Posted on April 14, 2014 at 17:20

Thanks Sung.Chen_chung for the reply.

 

From: sung.chen_chung

Posted: Wednesday, April 09, 2014 12:05 PM

Subject: Use of RTC in back up domain

Hi

''1. Is it responsibility of FW to manage the switch or is is managed bythe MCU hardware.? When Vdd is off and Vbat is present does themicrocontroller automatically goes to standby mode..? Do we need anykind of configuration for this...?''

It is the HW that manages the switch from RTC/SRAM powered to not powered.

It is the firmwares responsibility to make sure the RTC is setup/configured correctly.

No, when Vdd is not present - the processor is OFF

''2. How to know after power start whether the product up from a stand by mode or a power down reset. ''

    uint32_t lastRstState = RCC->CSR;

    // code to detect a warm reboot

    if ( RCC_CSR_SFTRSTF & lastRstState )

    {

        uartPrintf(''\n\r Warm boot (reset caused by software)'' );

    }

    else

    {

        uartPrintf(''\n\r Cold boot (Powered from Off)'' );

    }

rohitpai77
Associate II
Posted on April 23, 2014 at 09:51

Hello,

I have configured RTCEN bit in RCC_BDCR register. I am using LSI clock for RTC.

Kindly let me know whether I have to some additional configuration on RTC side. 

My undestand is when VBAT is present and VDD is off the RTC will still tick and be running the switch is managed by the Hardware. 

I am using RTC back-up register  validity to know whether I need to reconfigure RTC or not. 

I initialize RTC only when there is a cold start OR when there is invalid back-up register.

When there is a soft-reset my observation is that the back up register are valid but the RTC will not be enabled. I expect RTC to be enabled and running when there is a soft-reset...?

I need to reconfigure RTC when there is restart and before restart VBAT was absent. 

Thanks in Advance.

BR,

Rohit 

chen
Associate II
Posted on April 23, 2014 at 10:33

Hi

''Kindly let me know whether I have to some additional configuration on RTC side. ''

Yes, the RTC itself needs to be set up/configured, the prescalar, clock select etc

Please refer to the reference manual for your device.

''I am using RTC back-up register  validity to know whether I need to reconfigure RTC or not. 

I initialize RTC only when there is a cold start OR when there is invalid back-up register.''

Yes, knowing if the RTC has been set up for the first time is a tricky one.

I was hoping the RTC year would be full 4 digit but unfortunately it is only 2 digit.

so 00 will probably translate to year 2000.

(I have previously used schemes where year 0000 is invalid therefore the RTC has not been set up or had the date/time set).

The backup domain contains a small amount of battery back RAM. Use this to determine if the RTC has been set up before, ie have a statically allocated flag which is set to a known value when the RTC is configured where the value is not the default ie not 0x00 or 0xFF the more bytes in the flag the more secure.

''When there is a soft-reset my observation is that the back up register are valid but the RTC will not be enabled. I expect RTC to be enabled and running when there is a soft-reset...?''

Once the RTC is powered by a battery and it has been configured - it should stay running.

I have not tried it myself with this processor - so you will have to experiment, refer to the documentation and over come any issues.

rohitpai77
Associate II
Posted on April 23, 2014 at 12:36

Thanks for the quick response.

I will experiment and let you know the status.

Posted on April 23, 2014 at 13:30

> I was hoping the RTC year would be full 4 digit but unfortunately it is only 2 digit.

> so 00 will probably translate to year 2000.

That would see little use these days... ;)

This is in RM0090 (and probably the other RMs too):

''After a system reset, the application can read the INITS flag in the RTC_ISR register to

check if the calendar has been initialized or not. If this flag equals 0, the calendar has not

been initialized since the year field is set at its backup domain reset default value (0x00).''

JW

chen
Associate II
Posted on April 23, 2014 at 13:51

''it is only 2 digit.

> so 00 will probably translate to year 2000.

That would see little use these days... ;-)''

Showing my age ;)

Thanks for the additional info Jan

rohitpai77
Associate II
Posted on June 06, 2014 at 07:57

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6fP&d=%2Fa%2F0X0000000bsk%2FCIpcJ9Uq_urq4CjZQ0uhtqXRRp7AtMjFaghulTyUMXM&asPdf=false
chen
Associate II
Posted on June 06, 2014 at 10:22

Hi

A brief look through your code - looks like you are using the internal low speed oscillator.

Is that right?

I have not used the RTC myself, so I do not know for sure but one of the other experienced responders says that the LSI does not work running off the battery.

You must use the LSE and have an external crystal (32.768Khz)