175
8331B–AVR–03/12
Atmel AVR XMEGA AU
14.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.
Figure 14-10.
Event source selection for capture operation.
The event action setting in the timer/counter will determine the type of capture that is done.
The CC channels must be enabled individually before capture can be done. When the capture
condition occur, the timer/counter will time-stamp the event by copying the current CNT value in
the count register into the enabled CC channel register.
When an I/O pin is used as an event source for the capture, the pin must be configured for edge
sensing. For details on sense configuration on I/O pins, refer to
”Input Sense Configuration” on
. If the period register value is lower than 0x8000, the polarity of the I/O pin edge will be
stored in the most-significant bit (msb) of the capture register. If the msb of the capture register
is zero, a falling edge generated the capture. If the msb is one, a rising edge generated the
capture.
14.7.1
Input Capture
Selecting the input capture event action makes the enabled capture channel perform an input
capture on an event. The interrupt flags will be set and indicate that there is a valid capture result
in the corresponding CC register. At the same time, the buffer valid flags indicate valid data in
the buffer registers.
The counter will continuously count from BOTTOM to TOP, and then restart at BOTTOM, as
shown in
. The figure also shows four capture events for one capture channel.
Event System
CH0MUX
CH1MUX
CHnMUX
Rotate
Event channel n
Event Source Selection
CCA capture
CCB capture
CCC capture
CCD capture
Event channel 0
Event channel 1