CLC Interrupts

An interrupt will be generated upon a change in the output value of the CLCx when the appropriate interrupt enables are set. A rising edge detector and a falling edge detector are present in each CLC for this purpose.

The CLCxIF bit of the associated PIR register will be set when either edge detector is triggered and its associated enable bit is set. The INTP bit enables rising edge interrupts and the INTN bit enables falling edge interrupts.

To fully enable the interrupt, set the following bits:
If priority interrupts are not used:
  1. 1.Clear the IPEN bit of the INTCON register.
  2. 2.Set the GIE bit of the INTCON register.
  3. 3.Set the GIEL bit of the INTCON register.
If the CLC is a high-priority interrupt:
  1. 1.Set the IPEN bit of the INTCON register.
  2. 2.Set the CLCxIP bit of the respective IPR register.
  3. 3.Set the GIEH bit of the INTCON register.
If the CLC is a low-priority interrupt:
  1. 1.Set the IPEN bit of the INTCON register.
  2. 2.Clear the CLCxIP bit of the respective IPR register.
  3. 3.Set the GIEL bit of the INTCON register.

The CLCxIF bit of the respective PIR register must be cleared in software as part of the interrupt service. If another edge is detected while this flag is being cleared, the flag will still be set at the end of the sequence.