ATMEL AVR1506 User Manual

http://www.BDTIC.com/ATMEL
AVR1506: Xplain training - XMEGA clock system

Prerequisites

Required knowledge Basic knowledge of microcontrollers and the C programming language Completed AVR1500 Xplain Training – XMEGA™ Basics
Software prerequisites Atmel WinAVR/GCC 20100110 or later
Hardware prerequisities XPLAIN evaluation board JTAGICE mkII
Estimated completion time: 2 hours

1 Introduction

Atmel XMEGA has an advanced clock system, supporting a large number of clock sources. It incorporates both integrated oscillators, and external crystal oscillators and resonators. A high frequency Phase Locked Loop (PLL) and clock prescalers can be used to generate a wide range of clock frequencies. A calibration feature (DFLL) is available, and can be used for automatic run-time calibration of the internal oscillators. A Crystal Oscillator Failure Monitor can be enabled to issue a Non-Maskable Interrupt and switch to internal oscillator if the external oscillator fails. This training will cover the basics, but you will find more details of the XMEGA clock system in Application Note AVR1003.
®
AVR® Studio® 4.18 SP2 or later
8-bit Microcontrollers
Application Note
Rev. 8315A-AVR-06/10

2 Introduction to the XMEGA clock system

http://www.BDTIC.com/ATMEL
The Atmel XMEGA Clock System provides a large portfolio of clock sources, both internal and external. In addition, an internal PLL can be used to multiply selected clock sources with a factor ranging from 1x to 31x.
The internal 2 MHz and 32 MHz oscillators available have hardware support for automatic calibration against a 32 kHz clock source with the help of the built-in Digital Frequency Locked Loop (DFLL).
The Atmel XMEGA also has a dedicated Real Time Counter (RTC) which is typically used to keep track of time in more human friendly units like milliseconds, seconds, etc.
In the following chapters we will take a more detailed look into the different parts of the clock system.

2.1 Clock sources

In order to ease implementations, the default clock setting for the XMEGA is to start up running from an internal 2 MHz factory-calibrated source. In this way, if the default settings are sufficient, no external components or software configuration is required to start executing code.
There are five internal clock sources (including the internal PLL), ranging from an ultra low-power (ULP) 32 kHz RC oscillator to a 32 MHz factory-calibrated ring oscillator with auto-calibration features. All sources except the ULP 32 kHz RC oscillator can be used for the main system clock.
Any number of the internal sources can be enabled at any given time, even if none are used for the main system clock. Also, some clock sources might even be used for multiple purposes, such as the 32 kHz RC oscillator that can be used as a main system clock and as a clock source for the Real Time Counter module at the same time.
Some of the internal clock sources can be used as a reference to the internal PLL in order to generate even higher frequencies.
2
AVR1506
8315A-AVR-06/10
http://www.BDTIC.com/ATMEL
The following illustration shows the XMEGA clock system in more detail:
AVR1506
8315A-AVR-06/10
3

2.2 System clock prescaler

http://www.BDTIC.com/ATMEL
The system clock prescalers as shown in the illustration above can be illustrated in more details as follows:
The A, B and C prescalers gives us even more flexibility in the input clock selection. By using any of the available clock sources together with the prescalers, we are able to run the peripherals and CPU at various frequencies just by reconfiguring the A, B and C prescalers.

2.3 Runtime calibration

2.4 Real-time counter

The Atmel XMEGA has two built-in Digital Frequency Locked Loops (DFLLs) which can be used to improve the accuracy of the 2 MHz and 32 MHz internal oscillators. The DFLL compares the oscillator frequency with a more accurate reference clock to do automatic run-time calibration of the oscillator. The choices for the reference clock sources are:
32 kHz Calibrated Internal Oscillator
32 kHz Crystal Oscillator connected to the TOSC pins
When the DFLL is enabled it will count each oscillator clock cycle, and for each reference clock edge, the counter value is compared to the fixed ideal relationship between the two clocks. If the internal oscillator runs too fast or too slow, the DFLL will decrement or increment the corresponding DFLL Calibration Register value by one to adjust the oscillator frequency slightly.
The XMEGA has a dedicated counter for keeping track of time in a more human friendly way than regular timers, the Real Time Counter or RTC.
The reference clock for this timer is typically an external high accuracy 32 kHz watch crystal. This timer/counter is clocked asynchronously and is active in several of the low power sleep modes. This allows the microcontroller to keep track of time even when in sleep.
If less accuracy is needed, it is possible to use the internal 32 kHz RC oscillator to clock the RTC instead of an external crystal.
4
AVR1506
8315A-AVR-06/10
Loading...
+ 8 hidden pages