The missing clock detect (MCD) logic detects
OSCCLK failure, using SECCLK as the reference clock source. This circuit only detects
complete loss of OSCCLK and doesn’t do any detection of frequency drift on the OSCCLK.
This circuit monitors the OSCCLK (primary clock)
using the clock provided by the SECCLK (secondary clock) as a backup clock. This circuit
functions as below:
- The primary clock (OSCCLK) clock keeps
ticking a 7-bit counter (named as MCDPCNT). This counter is asynchronously reset with
XRSn.
- The secondary clock (SECCLK) clock keeps
ticking a 13-bit counter (named as MCDSCNT). This counter is asynchronously reset with
XRSn.
- Each time MCDPCNT overflows, the MCDSCNT
counter is reset. Thus, if OSCCLK is present or not slower than SECCLK by a factor of 64,
MCDSCNT never overflows.
- If OSCCLK stops for some reason or is
slower than SECCLK by at least a factor of 64, the MCDSCNT overflows and a missing clock
condition is detected on OSCCLK.
- The above check is continuously active,
unless the MCD is disabled using MCDCR register (by making the MCLKOFF bit 1).
- If the circuit ever detects a missing
OSCCLK, the following occurs:
- The MCDSTS flag is set.
- The MCDSCNT counter is frozen to
prevent further missing clock detection.
- The CLOCKFAIL signal goes high, which
generates TRIP events to PWM modules and sends NMIs to CPU1.NMIWD.
- PLL is forcefully bypassed and OSCCLK
source is switched to SECCLK (New, System Clock Frequency = SECCLK Freq
10MHz)/SYSDIV). In the meantime when the clock switches to SECCLK, the System runs on
PLL limp Clock.
- SYSPLLMULT.IMULT is zeroed out automatically in this case.
- While the MCDSTS bit is set, the
OSCCLKSRCSEL bits have no effect and OSCCLK is forcefully connected to SECCLK.
- PLLRAWCLK going to the system is
switched to SECCLK automatically.
- If the MCLKCLR bit is written (this is a
W=1 bit), MCDSTS bit is cleared and OSCCLK source is decided by the OSCCLKSRCSEL bits.
Writing to MCLKCLR also clears the MCDPCNT and MCDSCNT counters to allow the circuit
re-evaluate missing clock detection. If user wants to lock the PLL after missing clock
detection, switch the clock source to SECCLK (using OSCCLKSRCSEL register), do a MCLKCLR
and re-lock the PLL.
- The MCD is enabled at power up.
Figure 3-10 shows the missing clock logic functional flow.
Note:
- When XTAL is primary clock, SYSOSCDIV4
can be selected as secondary clock as this clock is more accurate than WROSCDIV8.
- On a complete clock failure when OSCCLK
is not operating, the operation can take a maximum time of 8192 SECCLK cycles (that is,
0.8192ms) before the CLOCKFAIL signal goes high, after which:
- NMI is generated
- OSCCLK is switched to SECCLK
- PWM Trip happens