The missing clock detect (MCD) logic detects OSCCLK failure, using INTOSC1 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 OSCLK (primary clock)
using the 10 MHz clock provided by the INTOSC1 (secondary clock) as a backup clock. This
circuit functions as following.
- The primary clock (OSCCLK) clock keeps ticking a 7-bit counter (named as MCDPCNT). This counter is asynchronously reset with XRS.
- The secondary clock (INTOSC1) clock keeps ticking a 13-bit counter (named as MCDSCNT). This counter is asynchronously reset with XRS.
- Each time MCDPCNT overflows, the MCDSCNT counter
is reset. Thus, if OSCCLK is present or is not slower than INTOSC1 by a factor of 64,
MCDSCNT never overflows.
- If OSCCLK stops for some reason or is slower than
INTOSC1 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 MCLKSTS 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 fires NMIs to CPU1.NMIWD and CPU2.NMIWD.
- PLL is forcefully bypassed and OSCCLK is switched to INTOSC1 (after the PLLSYSCLK divider). PLLMULT is zeroed out automatically in this case.
- While the MCLKSTS bit is set, the OSCCLKSRCSEL bits have no effect and OSCCLK is forcefully connected to INTOSC1.
- PLLRAWCLK going to the system is switched to
INTOSC1 automatically.
- If the MCLKCLR bit is written (W = 1 bit),
MCLKSTS bit are 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. To lock the PLL after a missing clock detection, switch the clock
source to INTOSC1 (using OSCCLKSRCSEL register), do a MCLKCLR, and re-lock the PLL.
- The MCD is enabled at power up. There is no
support for a missing clock detection, if INTOSC2 is failed from the device power-up.
Figure 3-10 shows the missing clock logic functional flow.
Note: On a complete clock failure when OSCCLK
is dead, it can take a maximum time of 8192 INTOSC1 cycles (that is, 0.8192 ms) before the
CLOCKFAIL signal goes high, after which:
- NMI is generated
- OSCCLK is switched to INTOSC1
- PWM trip happens