cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RB RTC Date Not Updating on Power Off with VBAT Enabled

KushalAgrawal
Associate II

Hello everyone,

I'm working with the STM32F103RB controller and have encountered an issue with the RTC functionality. While the time continues to update correctly when powered off (with VBAT enabled), the date resets to the default 01/01/2000 instead of retaining or updating the current date.

Has anyone experienced this behavior before, or can provide guidance on why only the time updates but not the date? Any advice on possible solutions or steps to troubleshoot would be greatly appreciated.

Thank you in advance for your help!

12 REPLIES 12

So share your code so others can help you efficiently.

Note F103 MCU doesn't feature a calendar but just a basic RTC counter.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

I’ve implemented the same code on the STM32F207 controller, and it works correctly. Both the date and time are successfully retained on the STM32F207 controller when VBAT is enabled.

Techn
Senior III

This confusion is expected.. STM32f103 has only a counter, there is no date and day, year etc. From the counter, we need to extract date , month, year etc. The date has to be stored in battery backed up register. Please read the comments in the file

Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc.c

 

##### WARNING: Drivers Restrictions #####

==================================================================

[..] RTC version used on STM32F1 families is version V1. All the features supported by V2

(other families) will be not supported on F1.

[..] As on V2, main RTC features are managed by HW. But on F1, date feature is completely

managed by SW.

[..] Then, there are some restrictions compared to other families:

(+) Only format 24 hours supported in HAL (format 12 hours not supported)

(+) Date is saved in SRAM. Then, when MCU is in STOP or STANDBY mode, date will be lost.

User should implement a way to save date before entering in low power mode (an

example is provided with firmware package based on backup registers)

(+) Date is automatically updated each time a HAL_RTC_GetTime or HAL_RTC_GetDate is called.

(+) Alarm detection is limited to 1 day. It will expire only 1 time (no alarm repetition, need

to program a new alarm)

If you feel a post has answered your question, please click "Accept as Solution".