2024-02-21 03:30 PM - edited 2024-02-21 03:37 PM
I'm trying to implement a RTC using the LSE crystal of Nucleo-h743zi board (Rev.B model). In addition, I want to backup the timestamp in case of power loss. Following the reference and user manuals, I finally have my RTC worked, using RTC backup registers and a external battery connected to VBAT (unsoldered SB156 and enabled mcu internal charger). So far so good. Unfortunately, after a couple of minutes I realize that RTC loses about 1 or 2 minute. This fault is getting bigger and after 24 hours this fault is about 1hour.
I use the RTC as an internal clock and I don't use tamper or wakeup pins. I have also read the errata sheet and I think there is no any conflict or interference with other pins or functions. If I choose to work with the LSI crystal, the aforementioned problem is not occurs. But in that case the backup function doesn't work. It is worth mentioning that the RTC has the same behavior even if I run any of the STM32cube examples pertaining to rtc.
Furthermore, I tried to measure the calibration output (512Hz) of RTC using my oscillator in order to calculate the error in ppm. But the error I took was by far less than the error mentioned above.
I have started to believe that 32.768kHz crystal is not working properly. Any ideas?
I provide you below my initialize functions of the RTC.
Thank you in advance.
Solved! Go to Solution.
2024-02-21 03:57 PM
Currently you've got it set to 63488 KHz, so probably time is running about 1/2 as fast as normal
2024-02-21 03:45 PM
Your prediv values look wrong, fix them
#define RTC_CLOCK_SOURCE_LSE
#ifdef RTC_CLOCK_SOURCE_LSI // 32000
#define RTC_ASYNCH_PREDIV 0x7F
#define RTC_SYNCH_PREDIV 0xF9
#endif
#ifdef RTC_CLOCK_SOURCE_LSE // 32768
#define RTC_ASYNCH_PREDIV 0x7F
#define RTC_SYNCH_PREDIV 0x00FF
#endif
2024-02-21 03:57 PM
Currently you've got it set to 63488 KHz, so probably time is running about 1/2 as fast as normal
2024-02-21 11:19 PM
“I have started to believe that 32.768kHz crystal is not working properly”
You may output 32768Hz LSE at MCO - usually PA8 pin and check its frequency with scope or frequency meter.
2024-02-22 01:25 PM
How I didn't see it? Yeah that was the problem. I have just fixed it and it seems that its working. Thanks a lot!!!