22.4.2.7 Capture Operations
To enable and use capture operations, the corresponding Capture Channel n Enable bit in the
Control A register (CTRLA.CAPTENn) must be set to ‘1’.
A capture trigger can be provided by the input event line (TC_EV), or by an asynchronous
I/O pin (WO[n]) for each capture channel, or by a TC event. To enable capture from the
input event line, the Event Input Enable bit in the Event Control register (EVCTRL.TCEI)
must be set to ‘1’. To enable capture from the I/O pin, the Capture On Pin
x Enable bit in the CTRLA register (CTRLA.COPENn) must be set to ‘1’.
- Capture on I/Os is only possible in 'Event' and 'Time-Stamp' capture action modes. Other modes can only use internal events (if I/O toggling is needed in other modes, then the I/O edge must be configured for generating internal events).
- Capture on an event from the Event System is possible in Event, PPW/PWP/PW, and Time-Stamp capture action modes. In this case, the event system channels must be configured to operate in asynchronous mode of operation.
- Depending on CTRLA.COPENn, channel n can be configured for I/Os or internal event capture (both are mutually exclusive). One channel can be configured for I/Os capture while the other uses internal event capture.
- Capture of the period and duty cycle on I/Os using PPW/PWP mode is possible using EIC and Event System.
- When the channel is used with an I/O
pin, write a ‘
1’ to the corresponding Invert Enable bit in the Drive Control register (DRVCTRL.INVENn) - When the channel is counting events
from the Event System, write a ‘
1’ to the TC Event Input Invert Enable bit in the Event Control register (EVCTRL.TCINV)
For input capture, the buffer register (CCBUF[n]) and the corresponding compare/capture register (CC[n]) function as a FIFO. When CC[n] is empty or read, any data in CCBUF[n] is transferred to CC[n]. The buffer valid flag is used to set the CC[n] interrupt flag (IF) and generate an optional interrupt, event, or DMA request. The CCBUF[n] register value can't be read, all captured data must be read from the CC[n] register.
