AN201
Rev 1.5 | 61/91
www.cmostek.com
the external clock, the latch is set to 1. On each rising edge of the sampling clock, the latch is cleared. If the main clock is still not
in the low level after a half cycle, it is detected as a fault.
5.6.2 Fail-Safe Operation
When the external clock fault occurs, the FSCM switches the device clock to the internal clock source, and the OSFIF flag bit of
the PIR1 register is set to 1. If both the OSFIF flag bit and the OSFIE bit of the PIR1 register are set to 1, an interrupt will be
generated. The device firmware will have the related handling to deal with problems caused by the fault clock. The system clock
will continue to use the internal clock source until the device firmware restarts the external oscillator successfully and switches
back to the external operation. The internal clock source selected by FSCM is determined by the IRCF<2:0> bit of the OSCCON
register. It can be configured before the fault occurs.
5.6.3 Fail-Safe Condition Clearing
A fail-safe condition is cleared after a reset, an execution of a Sleep instruction, or a reverse of the SCS bit of the OSCCON
register. After the SCS bit of the OSCCON register is modified, the OST will be restarted. When OST runs, the device continues
to operate with the INTOSC selected by OSCCON. After OST is timeout, the fail-safe condition is cleared and the device will
operate with the external clock source. The fail-safe condition must be cleared first then the OSFIF flag can be cleared.
5.6.4 Reset or Wake-up from Sleep
FSCM is designed to detect oscillator faults at any time after oscillator start-up timer (OST) expires. The OST suits for Wake-up
from Sleep or any type of reset. The OST cannot be used in the EC clock mode, so once a reset or wakeup completes, the FSCM
is in the active state. When the FSCM is enabled, the Two-Speed Start-up is enabled as well. Therefore, when the OST runs, the
device is always in the instruction execution state.
Notes:
1.
As the range of oscillator start-up time varies greatly, the Fail-Safe circuit is not active during the oscillation startup period
(e.g. after exiting reset or sleep). After an appropriate amount of time, users should check the OSTS bit of the OSCCON
register to verify whether the oscillator has successfully started and whether the system clock has been switched
successfully.