177
8331B–AVR–03/12
Atmel AVR XMEGA AU
14.7.3
Pulse Width Capture
Selecting the pulse width measure event action makes the enabled compare channel perform
the input capture action on falling edge events and the restart action on rising edge events. The
counter will then restart on positive edge events, and the input capture will be performed on the
negative edge event. The event source must be an I/O pin, and the sense configuration for the
pin must be set to generate an event on both edges.
shows and
example where the pulse width is measured twice for an external signal.
Figure 14-13.
Pulse width capture of an external signal.
14.7.4
32-bit Input Capture
Two timer/counters can be used together to enable true 32-bit input capture. In a typical 32-bit
input capture setup, the overflow event of the least-significant timer is connected via the event
system and used as the clock input for the most-significant timer.
The most-significant timer will be updated one peripheral clock period after an overflow occurs
for the least-significant timer. To compensate for this, the capture event for the most-significant
timer must be equally delayed by setting the event delay bit for this timer.
14.7.5
Capture Overflow
The timer/counter can detect buffer overflow of the input capture channels. When both the buffer
valid flag and the capture interrupt flag are set and a new capture event is detected, there is
nowhere to store the new timestamp. If a buffer overflow is detected, the new value is rejected,
the error interrupt flag is set, and the optional interrupt is generated.
14.8
Compare Channel
Each compare channel continuously compares the counter value (CNT) with the CCx register. If
CNT equals CCx, the comparator signals a match. The match will set the CC channel's interrupt
flag at the next timer clock cycle, and the event and optional interrupt are generated.
The compare buffer register provides double buffer capability equivalent to that for the period
buffer. The double buffering synchronizes the update of the CCx register with the buffer value to
either the TOP or BOTTOM of the counting sequence according to the UPDATE condition. The
Pulsewitdh (t
p
)
external signal
events
CNT
MAX
BOTTOM
"capture"