SAM3S8/SD8 Software Package: PMC Clock Switching Example

SAM3S8/SD8 Software Package 1.2

# PMC Clock Switching Example

## Purpose

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

## Requirements

This package can be used with SAM3S evaluation kits two.

## Description

Upon startup, the program configure pios for UART,PCK and botton. The baud rate of UART is configured as 2400 bps. The application does some printf with the current configuration (except 32KHz slow clock ) and waits for button pressed to switch to next configuration. PCK1 Outputs can be selected from the clocks provided by the clock (PLLA, PLLB, SLCK, MAINCK) and driven on the pin PCK1 on PA17 (Peripheral B). After the clock switchs, the PCK1 output signal can be measured by scope compare with the clock configuration.

- The Clock Generator integrates a 32,768 Hz low-power oscillator. In order to use this oscillator, the XIN32/PA7 and XOUT32/P8 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 command is made by function _PmcEnableExternal32K().
- 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 are available. It can be done through function _PmcMainClockSwitchFastRc(). 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 _PmcMainClockSwitchMainOsc() show how to enable the oscillator.
- The PMC features one Divider/PLL Blocks that permit a wide range of frequencies to be selected on either the master clock, the processor clock or the programmable clock outputs. Function _PmcConfigurePllClock() descripts the deatil how to configure PLLA/B.

## Usage

1. Build the program and download it inside the evaluation board. Please refer to the SAM-BA User Guide, the GNU-Based Software Development application note or to the IAR EWARM User and reference guides, depending on your chosen solution.
2. On the computer, open and configure a terminal application (e.g. HyperTerminal on Microsoft Windows) with these settings:
   - 2400 bauds
   - 8 bits of data
   - No parity
   - 1 stop bit
   - No flow control
3. Start the application.
4. In the terminal window, the following text should appear:

            -- Pmc clock Switching Example xxx --
            -- xxxxxx-xx
            -- Compiled: xxx xx xxxx xx:xx:xx --

5. Press one of the keys listed in the menu to perform the corresponding action.

## References

- pmc_clock_switching/main.c

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines