Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PMC Clock Switching example

Introduction

This example shows how to switch from a clock to another (PLL, SLCK, MAINCK) or change divider.

Requirements

This package can be used with SAM evaluation kits.

Main files:

Description of the Example

Upon startup, the program configures PIOs for UART, PCK and buttons. The baud rate of UART is configured as 2400 bps. The application performs some printf actions with the current configuration (except 32KHz slow clock ) and waits for the button pressed to switch to the next configuration. The PCK clock can be selected among PLLA, UPLL, SLCK, MAINCK and driven on the PCK0(For SAM4C_EK, PCK2 is used) pin. After the clock switches, the PCK output signal can be measured by oscilloscope and compared with the clock configuration.

  • The Clock Generator integrates a 32,768 Hz low-power oscillator. In order to use this oscillator, the XIN32 and XOUT32 pins must be connected to a 32,768 Hz crystal. The user can select the crystal oscillator to be the source of the slow clock, as it provides a more accurate frequency. The switch is made by function pmc_switch_sclk_to_32kxtal().
  • MAINCK is the output of the Main Clock Oscillator selection: either the Crystal Oscillator or 4/8/12 MHz Fast RC Oscillator. The user can select the output frequency of the Fast RC Oscillator: either 4 MHz, 8 MHz or 12 MHz is available. It can be done through function pmc_switch_mainck_to_fastrc(). The user can also select the 3 to 20 MHz Crystal oscillator to be the source of MAINCK, as it provides a more accurate frequency. The function pmc_switch_mainck_to_xtal() shows how to enable the oscillator.
  • The PMC features a PLL block that permits a wide range of frequencies to be selected on either the master clock, the processor clock or the programmable clock. Function pmc_switch_mck_to_pllack() can be used to configure the PLLA.

Compilation Info

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

Contact Information

For further information, visit Microchip.
Support and FAQ: https://www.microchip.com/support/