
140
8210C–AVR–09/11
Atmel AVR XMEGA D
A counter wraparound can occur in any mode of operation when up-counting without buffering,
as shown in
. This due to the fact that CNT and PER are continuously compared,
and if a new TOP value that is lower than current CNT is written to PER, it will wrap before a
compare match happen.
Figure 12-8.
Unbuffered dual-slope operation.
When double buffering is used, the buffer can be written at any time and still maintain correct
operation. The period register is always updated on the UPDATE condition, as shown for dual-
slope operation in
. This prevents wraparound and the generation of odd waveforms.
Figure 12-9.
Changing the period using buffering.
12.7
Capture Channel
The CC channels can be used as capture channels to capture external events and give them a
timestamp. To use capture, the counter must be set for normal operation.
Events are used to trigger the capture; i.e., any events from the event system, including pin
change from any pin, can trigger a capture operation. The event source select setting selects
which event channel will trigger CC channel A. The subsequent event channels then trigger
events on subsequent CC channels, if configured. For example, setting the event source select
to event channel 2 results in CC channel A being triggered by event channel 2, CC channel B
triggered by event channel 3, and so on.
CNT
MAX
New TOP written to
PER that is higher
than current CNT
New TOP written to
PER that is lower
than current CNT
"update"
"write"
Counter Wraparound
BOTTOM
CNT
MAX
New Period written to
PERBUF that is higher
than current CNT
New Period written to
PERBUF that is lower
than current CNT
"update"
"write"
New PER is updated
with PERBUF value.
BOTTOM