Datasheet

158
XMEGA B [DATASHEET]
8291B–AVR–01/2013
Figure 13-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 page 132. 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.
13.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 Figure 13-11. The
figure also shows four capture events for one capture channel.
Figure 13-11.Input capture timing.
13.7.2 Frequency Capture
Selecting the frequency capture event action makes the enabled capture channel perform an input capture and restart on
positive edge events. This enables the timer/counter to measure the period or frequency of a signal directly. The capture
result will be the time (T) from the previous timer/counter restart until the event occurred. This can be used to calculate
the frequency (f) of the signal:
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
events
CNT
TOP
BOTTOM
Capture 0 Capture 1
Capture 2
Capture 3
f
1
T
---
=