2024-11-04 07:47 PM - last edited on 2024-11-07 05:24 AM by SofLit
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!
Solved! Go to Solution.
2024-11-13 03:32 AM
So share your code so others can help you efficiently.
Note F103 MCU doesn't feature a calendar but just a basic RTC counter.
2024-11-13 03:36 AM
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.
2024-11-13 11:10 PM
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)