Nucleo-STM32H563ZI RTC SSR Value Jump Back
I am programming a Nucleo-STM32H563ZI and get a problem while trying to get subseconds value in RTC.
Below is the main code:
unsigned prev_ssr = 0;
char print_buf[32] = { 0 };
unsigned this_ssr;
int count;
while (1)
{
this_ssr = READ_REG(RTC->SSR);
if (this_ssr != prev_ssr) {
count = sprintf(print_buf, "%05u-->%05u\n", prev_ssr, this_ssr);
HAL_UART_Transmit(&huart3, (uint8_t const*)print_buf, count, 10);
prev_ssr = this_ssr;
}
}
SSR SynchPrediv is 255 as default. It takes about 3.9ms to decrease by 1.
UART baudrate is 115200. It takes about 1.2ms to send a data package which has 14 bytes.
So this program could catch every normal change of SSR value. And the UART output data verify this.
But in the UART output data, I found some lines like this:
00030-->00029
00029-->00028
00028-->00031
00031-->00027
00027-->00026
00026-->00025
That tells us the SSR value would jump back sometimes.
And it happens about 3 or 4 times per second! I don't know whether some jumps escape.
The jump back value is always 3 (31-8= 3).
Do I take some mistake in STM32CubeIDE project or my code?
