Hello Xiangjun,
This is exactly what I tried to do expecting the outcome that you have illustrated. But it does not work that way.
Following is my code.
=====================
void init_rtc(){
rtc_config_t rtcConfig;
RTC_GetDefaultConfig(&rtcConfig);
RTC_Init(RTC, &rtcConfig);
/* Select RTC clock source */
BOARD_SetRtcClockSource();
}
void BOARD_SetRtcClockSource(void)
{
SIM->SOPT1 &= ~SIM_SOPT1_OSC32KSEL_MASK;
SIM->SOPT1 |= SIM_SOPT1_OSC32KSEL(3); // 1kHz LPO
RTC_StopTimer(RTC);
RTC->TPR = (32768 - 1000); // use 1kHz internal clock to generate 1s time base by adjusting the prescaler value
uint32_t currSeconds = RTC->TSR;
PRINTF("\r\n TIME NOW = %d", rtc_get_seconds());
RTC_StartTimer(RTC);
}
=====================
In a while(1) loop in the main(), I am reading and printing the value of RTC->TSR.
The first increment happens in 1 second but the next increment of this register happens always only after 32 seconds.
Could you please try it out by modifying the example SDK_2.0_MKL03Z32xxx4_16.02.2017\boards\frdmkl03z\driver_examples\rtc?
Will it continue to increment if the MCU then goes to VLLS3 state and comes back to RUN state?
Appreciate your help.