Overview:
This application demonstrates a runtime XOSC32K (external 32KHz crystal oscillator) failure detector, using hardware Clock failure detection with safe clock switch.
Use XOSC32K as the clock source of GCLK2, OSCULP32K is the safe clock. The GCLK2 output PIN will output 32K frequency signal, even though the XOSC32K is failed.
When a clock failure is detected, the XOSC32K clock is replaced by the safe clock in order to maintain an active clock during the XOSC32K clock failure. The safe clock source is the OSCULP32K oscillator clock.
In the example application, the GCLK2 reference clock is automatically switched between the internal and external 32KHz clock sources depending on the external reference availability.
This application has been tested on following boards:
Connect an oscilloscope to the pin:
Run the example application, then press and hold the board button to turn off the external XOSC32K crystal clock source to observe the fail-over to the internal clock source. Releasing the button will re-enable the external XOSC32K crystal.
The board LED will be turned on when the external crystal is used, and will be turned off when the internal OSCULP32K oscillator is used due to a XOSC32K failure detection.
This software was written for the GNU GCC and IAR for ARM. Other compilers may or may not work.
For further information, visit http://www.microchip.com.