When I use an external clock source to provide a clock signal, I may encounter an embarrassing situation where the external clock source suddenly crashes without a little omen. This is equivalent to the system collapse. Therefore, a healthy and robust system must have a monitoring and dispatching agency, just like a night watchman. The PIC16 provides a peripheral with this capability, the Fault Protection Clock Monitor (FSCM). The Fail-Safe Clock Monitor (FSCM) automatically dispatches the device to the internal clock source to continue operation in the event of an external oscillator or external clock failure. If Oscillator mode is selected, the FSCM can detect an oscillator failure at any point after the Oscillator Start-up Timer (OST) has expired. When the external clock mode is selected, the FSCM can detect an oscillator failure as soon as the device is released from reset. The FSCM is enabled by setting the FCMEN bit in the configuration word. The FSCM can be used in external oscillator mode (HS), external clock mode (ECH, ECM, ECL, and EXTRC) and secondary oscillator (SOSC). Fail-Safe Clock Monitor (FSCM) SCS (in the OSCCON register) = 00, the clock source is determined by FOSC<1:0> in the Configuration Word. Bit 13 (FCMEN) of the configuration word CONFIG1 is set to 1 to enable the fail-safe clock monitor; bit 2-0 (FOSC<2:0>) = 010, using the external crystal as the clock source. Fault protection condition clear SCS<1:0> = 1x: Modify the SCS bit in the OSCCON register to select the internal oscillator block. This resets the Oscillator Start-up Timer OST and allows it to work again. OSFIF = 0: Clear the OSFIF bit of the PIR2 register (OSFIF will be set by hardware when a fault occurs, triggering an interrupt, which is skipped here). SCS<1:0> = 00: Modify the SCS bit of the OSCCON register to select the FOSC Configuration Word clock selection. This starts the Oscillator Start-up Timer OST. The CPU will continue to rely on the internal oscillator to operate until the OST count is reached. When the OST times out, the clock module will switch to the external crystal and the fault protection condition will be cleared. 1.27Mm Box Header Connector,Smt 1.27Mm Box Header Connector,Smt Vertical Type Box Header Connector,1.27Mm Pitch Box Header Connector Shenzhen CGE Electronics Co.,Ltd , https://www.cgeconnector.com