This example shows how to switch between various system clock sources and prescalers at run time.
All AVR XMEGA devices can be used.
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.
Note that the state diagram indicates the prescaling from the clock source to each of the available clock signals: clk_PER4, clk_PER2 and clk_PER + clk_CPU.
The clock frequency decreases with each step in the sequence, until it resets to the initial clock setting. A timer/counter (LED_TC, TC_SYSCLK_PORT and TC_SYSCLK_MODULE) is used in PWM mode to blink a LED, thus giving a visual indication of the peripheral clock frequency.
This software was written for the GNU GCC and IAR for AVR. Other compilers may or may not work.
For further information, visit Microchip.