Microchip® Advanced Software Framework

SAM XOSC32K Runtime Failure Detector

Overview:

Introduction

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:

  • SAM L22 Xplained Pro
  • SAM C21 Xplained Pro
  • SAM R30 Xplained Pro

Usage

Connect an oscilloscope to the pin:

  • SAM L22 Xplained Pro: PA15
  • SAM C21 Xplained Pro: PA16
  • SAM R30 Xplained Pro: PA14

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.

Compilation Info

This software was written for the GNU GCC and IAR for ARM. Other compilers may or may not work.

Contact Information

For further information, visit http://www.microchip.com.