171
8331B–AVR–03/12
Atmel AVR XMEGA AU
A prescaled peripheral clock and events from the event system can be used to control the coun-
ter. The event system is also used as a source to the input capture. Combined with the
quadrature decoding functionality in the event system (QDEC), the timer/counter can be used
for quadrature decoding.
14.4
Clock and Event Sources
The timer/counter can be clocked from the peripheral clock (clk
PER
) or the event system, and
shows the clock and event selection.
Figure 14-3.
Clock and event selection.
The peripheral clock is fed into a common prescaler (common for all timer/counters in a device).
Prescaler outputs from 1 to 1/1024 are directly available for selection by the timer/counter. In
addition, the whole range of prescaling from 1 to 2
15
times is available through the event system.
Clock selection (CLKSEL) selects one of the prescaler outputs directly or an event channel as
the counter (CNT) input. This is referred to as normal operation of the counter. For details, refer
to
”Normal Operation” on page 172
. By using the event system, any event source, such as an
external clock signal on any I/O pin, may be used as the clock input.
In addition, the timer/counter can be controlled via the event system. The event selection
(EVSEL) and event action (EVACT) settings are used to trigger an event action from one or
more events. This is referred to as event action controlled operation of the counter. For details,
refer to
”Event Action Controlled Operation” on page 173
. When event action controlled opera-
tion is used, the clock selection must be set to use an event channel as the counter input.
By default, no clock input is selected and the timer/counter is not running.
14.5
Double Buffering
The period register and the CC registers are all double buffered. Each buffer register has a buf-
fer valid (BV) flag, which indicates that the buffer register contains a valid, i.e. new, value that
can be copied into the corresponding period or CC register. When the period register and CC
channels are used for a compare operation, the buffer valid flag is set when data is written to the
buffer register and cleared on an UPDATE condition. This is shown for a compare register in
clk
PER
/
2
{0,...,15}
CKSEL
CNT
EVACT
clk
PER
/
{1,2,4,8,64,256,1024}
Common
Prescaler
clk
PER
event channels
(Encoding)
Event System
EVSEL
Control Logic
events