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 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)
2024-11-04 10:53 PM
Hello @KushalAgrawal @and welcome to the community,
« 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. »
This statement is not clear and there is something contradictory here. It continues to update but the date resets!. Please clarify
2024-11-05 01:09 AM
Thank you for your response.
To clarify, here is the issue with a specific example:
When I turn off the main power at 10:00:00 on 05/11/2024 and then restore power an hour later, the time is correctly retained and updates to 11:00:00. However, the date resets to 01/01/2000 instead of continuing from 05/11/2024.
So in summary:
I hope this example clarifies the issue. Please let me know if you need any additional details. Thank you again for your assistance!
2024-11-05 01:13 AM
What Hardware are you using? ST board? custom board? Blue/Black pill?
2024-11-05 01:18 AM
I’m using the Nucleo F103RB board along with a CR2032 coin cell for RTC backup power. After turning off the main power, the coin cell supplies the backup power to the RTC.
Let me know if any additional details would be helpful.
2024-11-05 01:29 AM
What about SB45 solder bridge? soldered or not?
2024-11-05 01:42 AM
Yeah,Thank you for the reminder! I’ve checked the UM1724 reference manual and have removed the SB45 solder bridge as suggested for enabling the coin cell backup.
2024-11-05 01:53 AM
While I don't know what exactly causes your problems, generally, both Cube and SPL for 'F1 (which does not have native calendar i.e. time/date timekeeping in the RTC) use a bizarre mechanism where they use the RTC only to maintain time, and store the datum separately in the backup registers, incrementing it "manually" upon detecting time crossing the 12h/24h boundary.
I recommend to avoid these libraries and use the RTC natively as an epoch counter and use the standard <time.h> facilities to convert it from/to calendar format.
JW
2024-11-13 02:54 AM
Hello @KushalAgrawal ,
Your comment is not clear. Did you solve your issue?
2024-11-13 03:28 AM
Nope, I am not getting any solutions for these controller [STM32F103RB].