RTC osc. monitor

cancel
Showing results for 
Search instead for 
Did you mean: 

RTC osc. monitor

150 Views
Contributor I

Hello,
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 */
CLOCK_SetRtcOscMonitorMode(kMCG_MonitorInt);

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;
}
else
{
GPIO_TogglePinsOutput(GPIOB, 1u << BOARD_PIN7); // TODO : remove or debug only
status = kStatus_Success;
}

CLOCK_ClearStatusFlags(kMCG_RtcOscLostFlag);

return status;
}

This is my main function:

int main(void)
{
BOARD_BootClockRUN();
BOARD_InitPins();
Board_GPIO_Config();
CheckRTC_OscStable(); // 1st call to check rtc


/* Enter an infinite loop */
while(1)
{
delay(500U);
CheckRTC_OscStable();
}

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?

Tags (2)
0 Kudos
7 Replies

5 Views
NXP TechSupport
NXP TechSupport

Hi,

There is no such a data in KM34's datasheet. Since Kinetis family share same IP and manufacturing process, we can refer to other device's datasheet. This time is tirefsts. Both KL82 and K80 is 32us. K60 is max 4us. So, I think this time is very short, less than 1ms.

Regards,

Jjing

0 Kudos

5 Views
NXP TechSupport
NXP TechSupport

Hi Matteo,

The 32kHz oscillator start up time is 1000ms. Please see the datasheet page 23, table 23.

Regards,

Jing

0 Kudos

5 Views
Contributor I

Hello Jing Pan,

thanks for the answer, but it does not fit my question.

My question is about the rtc oscillator monitor and not the rtc oscillator.

I'd like to know how long does the monitor take to be fully operational, because the monitor (after being set) needs some time to set flags correctly (see code and considerations above).

Thank you.

Matteo

0 Kudos

5 Views
NXP TechSupport
NXP TechSupport

Hi Matteo,

The RTC monitor use IRC as clock base. It counts RTC clock. If it is out of range, MCG_C8.LOCS1 will be set. When the program is running, it IRC should be stable. But during the long start time, RTC counter sometimes in range, but sometimes not.

Regards,

Jing

0 Kudos

5 Views
Contributor I

Hello Jing Pan,

thanks for the answer.

You mean SlowIRCLK?

You are talking about paragraph 35.4.4 of the manual?

In figure 35.1 seems the clock monitor can be sourced also from external crystal osc., or am I misunderstanding?

Regards.

0 Kudos

5 Views
NXP TechSupport
NXP TechSupport

Hi,

Yes, this monitor can check both external OSC and RTC. MCG_C6.CME0/MCG_C8.CME1 enable the function. From figure 35.1, it seems that it use the slow clock.

Regards,

Jing

0 Kudos

5 Views
Contributor I

Hello,

I'm using an external osc in my application, and I've never enabled the slowclock.

But paragraph 35.4.4 of the manual says "If any of the CME bits are asserted the slow internal reference clock is enabled along with the enabled external clock monitor".

So probably, after being set, the monitor gives "false positives" results because the slowclock is not yet stable. Do you agree?

So let's go back to my question: how long does the monitor take to be fully operational (no false positives)?

In other words, how long does the slowclock take to be stable?

Regards.

0 Kudos