AnsweredAssumed Answered

RTC osc. monitor

Question asked by Matteo Perego on Jun 18, 2019
Latest reply on Jul 4, 2019 by Jing Pan

I'm using MKM34Z256VLL7 and I'm trying to manage the rtc oscillator loss monitor and its flags.
At power up, the rtc monitor is set (at the end of BOARD_BootClockRUN() function):


/* Set Rtc osc. monitor mode */


then I wrote a function to check if rtc osc. is lost or not.
This is the function:


status_t CheckRTC_OscStable(void)
status_t status = kStatus_Fail;

if (CLOCK_GetStatusFlags() & kMCG_RtcOscLostFlag)
// Toggle pin to alert RTC osc. is lost
GPIO_TogglePinsOutput(GPIOA, 1u << BOARD_PIN1); // TODO : remove or debug only
status = kStatus_Fail;
GPIO_TogglePinsOutput(GPIOB, 1u << BOARD_PIN7); // TODO : remove or debug only
status = kStatus_Success;


return status;


This is my main function:


int main(void)
CheckRTC_OscStable(); // 1st call to check rtc

/* Enter an infinite loop */

return 0;


The 1st call to CheckRTC_OscStable() returns kStatus_Success even if rtc osc is not stable.
The 2nd call to CheckRTC_OscStable() returns kStatus_Fail (that's right because rtc osc is not yet stable), and then after some hundreds ms
the function returns kStatus_Success (that's right, finally rtc osc is stable).

Probably there must be a delay between the configuration of the osc monitor mode and the 1st check of the flags, but I didn't find this data in the datasheet,
can you help me? How long does the monitor take to be fully operational?