Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Common API for Clocks Control / Example 3 for SAM4L8 Xplained Pro Documentation

Introduction

This example shows how to switch between various system clock sources and prescalers at run time.

Main files:

Device Info

All SAM4L devices can be used.

Description of the example

The clock system is reconfigured every time the user presses a button (NEXT_BUTTON) to use the next clock source and prescaler settings shown in the state diagram below.

Sequence of clock source and prescaler settings

The Systick is used to generate periodic interrupts based on its CPU clock. With each interrupt, a LED (LED_EXAMPLE_OUTPUT) is toggled, thus giving a visual indication of the system clock frequency.

Compilation Info

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

Contact Information

For further information, visit Microchip.