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.

For example, assume that OPS[3:0] = 0001, specifying an interrupt on every second capture event. The following sequence of events will produce a single CCPxIF, as shown:
  1. Turn on module; event count = 0.
  2. Capture first event; FIFO contains one entry, event count = 1.
  3. Read FIFO; FIFO is empty, event count = 0.
  4. Capture second event; FIFO contains one entry, event count = 1.
  5. Capture third event; FIFO contains two entries, event count = 2, set CCPxIF.
  6. Clear interrupt count when interrupt is set (event count = 0).
  7. Capture fourth event; FIFO contains three entries, event count = 1.
  8. Read FIFO three times; FIFO is empty, interrupt count = 0.
  9. Capture fifth event; FIFO contains one entry, event count = 1.
  10. Read FIFO; FIFO is empty, event count = 0.