2023-01-10 09:06 AM
I am using an STM32H753I-EVAL2 and the STM32CubeIDE. I am able to set up the RTC and print out its counting time. I do it on a FreeRTOS thread. I have JP11 configured such that VBAT is connected to the battery.
I set my RTC_TimeTypeDef globally:
RTC_TimeTypeDef sTime = {0};
My task made with FreeRTOS to always get the time and print it:
void StartDefaultTask(void *argument) {
for(;;) {
HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN);
uint16_t milliSec = 1000 - (sTime.SubSeconds * 1000) / sTime.SecondFraction;
printf("-> Time Value: %.2d:%.2d:%.2d:%.3d\r\n", sTime.Hours, sTime.Minutes, sTime.Seconds, milliSec);
}
}
When I have JP11 configured such that VBAT is connected to +3.3 V, and I unplug the primary power source and replug it back in, the time resets to 00:00:00:000. Yet when VBAT is connected to the coin battery, the time resumes from the time when it was unplugged.
I want it to continue counting while the battery powers it. What do I need to change?
Thank you,
Jared
2023-01-10 02:04 PM
> When I have JP11 configured such that VBAT is connected to +3.3 V, and I unplug the primary power > source and replug it back in, the time resets to 00:00:00:000.
Isn't that the expected behaviour?
> Yet when VBAT is connected to the coin battery, the time resumes from the time when it was unplugged.
Measure voltage of the battery.
JW
2023-01-11 06:53 AM
Thank you for the response.
> Yes, that is expected behavior. I should have said that, I was trying to add more context.
> The battery is reading 2.77V. It is a 3V battery. Do you reckon that is the issue?
2023-01-12 10:44 AM
After a deep dive into some documentation, I found that I needed the RTC Clock Mux to be set to LSE instead of the default LSI. This has led to its own issues (LSE is never set to ready in SystemClock_Config), but I believe it could help anyone who has a similar issue in the future.
2023-01-12 12:45 PM
Typically there is no need to wait for LSE ready in system startup.
2023-01-13 06:27 AM
Right I agree. Leads me to believe there is a deeper issue with LSE but I am not sure where to look for it.
2023-01-14 01:10 AM
Do you have a crystal at the LSE pins, and solder bridges/jumpers set accordingly?
JW