27.4.3.3 Input Capture Interrupts
While in Input Capture mode, the module has the ability to generate an interrupt upon a capture event. A capture event is defined by writing a timer value to the FIFO.
The OPS[3:0] control bits (CCPxCON1[27:24]) select the interrupt postscaler, specifying
the number of capture events that must occur before an interrupt is generated. Options
range from an interrupt on every capture to every fourth capture. The first capture
event is defined as the capture event occurring after a mode change from the Disabled
state (CCPON = 0
) or after ICBNE = 0
.
On buffer overflow, the capture events cease and the interrupts stop unless OPS[3:0] =
0000
(interrupt on every capture). Clearing the FIFO by reading it
also clears the internal interrupt counter and may affect when an interrupt is
generated.
Applications often use the Input Capture pins as auxiliary external interrupt sources. In Edge Detect mode, interrupts occur regardless of FIFO overflow, as specified by OPS[3:0]. There is no need to perform a dummy read on the Input Capture buffer to clear the event because the capture interrupt events will not stop when the FIFO Overflow (ICOV) flag becomes set. This allows a continuous stream of capture events to trigger interrupt events without the need to continuously empty the FIFO.
0001
, specifying an interrupt on
every second capture event. The following sequence of events will produce a single
CCPxIF, as shown:- Turn on module; event count = 0.
- Capture first event; FIFO contains one entry, event count = 1.
- Read FIFO; FIFO is empty, event count = 0.
- Capture second event; FIFO contains one entry, event count = 1.
- Capture third event; FIFO contains two entries, event count = 2, set CCPxIF.
- Clear interrupt count when interrupt is set (event count = 0).
- Capture fourth event; FIFO contains three entries, event count = 1.
- Read FIFO three times; FIFO is empty, interrupt count = 0.
- Capture fifth event; FIFO contains one entry, event count = 1.
- Read FIFO; FIFO is empty, event count = 0.