RTC read time with and without shadow register and reading twice
Hello,
I've a spezial question about the reading of the RTC date/time. In my project are used the STM32G030F6 with SYSCLK=64MHz and RTCCLK=32768Hz. Per reset value the BYPSHAD=0.
Now I read the date/time with the follwoing consecutive two lines:
const uint32_t time_u32 = READ_BIT (RTC->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU));
const uint32_t date_u32 = READ_BIT (RTC->DR, (RTC_DR_WDU | RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | RTC_DR_DU | RTC_DR_YT | RTC_DR_YU));
I can change it to reduce the runtime to:
const uint32_t time_u32 = RTC->TR;
const uint32_t date_u32 = RTC->DR;
We have don't use any IRQ's during reading the date/time.
In the referenzmanual is describe that the shadow register are set every RTCCLK cycle. Also it is describe that when I have a verry fast SYSCLK than is not used a twice read of the date/time to check if it changed during the read.
It is not complete clear when the shadow register are refreshed. In the RM is describe that the read from the SSR or TR the shadow register refresh locks and the read from the DR this unlock. But what is the beahviour when I only read the TR or SSR register? If the RSF flag during normal operation of the RTC reset or allways set?
What happens to the date/time valies if they are read at the exact time of the change? As excample: the date/time are changed after the 1st source code line bevore the 2nd source code line read the next value?
Thanks for clarify this, Bernd
