2017-02-23 01:49 AM
I am using STM32F103 in my new application. I have used STM32Cube to generate my code including Internal RTC. My
problem is that the time is ok saved when reseted but date is always reset. when i inspected the code i found that the HAL_RTC_SetDate() function is not setting the RTC_CNTH and RTC_CNTL registers appropriately. Is it a bug or is there any other way of doing this. when we add day shouldn't the RTC_CNTH and RTC_CNTL added with (24hrs x 60 Mins x 60 Secs) this is not happening.#cube-mx #hal-library2017-06-02 12:30 AM
For me its the same. I use RTC_SetDate and RTC_SetTime to set the date and the time. After that I use RTC_GetDate and RTC_GetTime to read the date and the time. The time works, but the date is still the same. If I do then a system reset by pressing the reset button, the date can be read properly. So writing date and time seems to work. But reading does not work.
2017-06-02 06:33 AM
I don't know if this is related or not:
I had an issue a few years ago with the STM32F407 (using SPL). After changing the date, RTC_GetDate was not returning the correct date for sometimes upwards of 100 attempts (my test was to read and display the time and date every second). I never resolved the cause, but I came up with a rework; if I first called RTC_GetTime BEFORE calling RTC_GetDate, all was well. RTC_WaitForSynchro did not correct the problem.
2017-06-06 07:48 AM
I had the same problem (on STM32L152)... and I found this subject last week...
I tried to invert the call to have
RTC_GetDate() AFTER
RTC_GetTime()... and I got good results. As a feeling, I guess it solved the problem......... h
oping it is not a coincidence!
2017-06-06 08:12 AM
This is a feature. Read the fine manual, RTC chapter, Reading the calendar subchapter:
To ensure consistency between the 3 values, reading either RTC_SSR or
RTC_TR locks the values in the higher-order calendar shadow registers until RTC_DR isread.I believe this is mentioned even in the Cube documentation (I am not going to provide pointers to that).
JW
2024-08-07 06:32 AM
I myself spent the whole day to figure it out. Implemented the clock using third-party functions. And only in the evening while analyzing code HAL_RTC_GetTime() did it come to me. The function counts only one day days_elapsed in a circle and counts days. ->>
/* Update date */
RTC_DateUpdate(hrtc, days_elapsed);
They need to be stored in another memory, for example, in backup registers.