2020-01-30 06:21 AM
To keep the count running, it was necessary to comment on this line:
(file: stm32f4xx_hal_rtc.c line: 864):
// sTime->SubSeconds = (uint32_t)(hrtc->Instance->SSR);
Ref.: (ivan239955) https://community.st.com/s/question/0D50X00009XkbIt/rtc-lselsi-settings-from-stm32cubef4-does-not-work-solved-2-bugs-in-cube
2023-12-18 01:58 AM
Hah, funky. I thought I had bug in code for H7. Started writing my function from scratch and found out that getting time with HAL lib actually freezes getting time. What is funny I cam across this problem back from 2y ago. Despite that good to have HAL as startign point.
Here effect before and after fix:
2023-12-18 07:42 AM
Actually seems I was wrong. I started getting some otther errors related to calendar. The I found comment:
" * @note You must call HAL_RTC_GetDate() after HAL_RTC_GetTime() to unlock the values
* in the higher-order calendar shadow registers to ensure consistency between the time and date values.
* Reading RTC current time locks the values in calendar shadow registers until Current date is read."
Finally it works as expected:
void rtc_device_get_time_date(rtc_time_t* time, rtc_date_t* date) {
RTC_TimeTypeDef rtc_time;
RTC_DateTypeDef rtc_date;
HAL_RTC_GetTime(&hrtc, &rtc_time, RTC_FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &rtc_date, RTC_FORMAT_BIN);
if (time != NULL) {
time->hour = rtc_time.Hours;
time->minute = rtc_time.Minutes;
time->second = rtc_time.Seconds;
}
if (date != NULL) {
date->year = rtc_date.Year;
date->month = rtc_date.Month;
date->day = rtc_date.Date;
}
}