The following steps should be followed when setting up
the CLC:
- 1.Disable CLC by
clearing the EN bit.
- 2.Select desired
inputs using the CLCnSEL0 through CLCnSEL3 registers.
- 3.Clear any ANSEL
bits associated with CLC input pins.
- 4.Set all TRIS bits
associated with inputs. However, a CLC input will also operate if the pin is
configured as an output, in which case the TRIS bits should be cleared.
- 5.Enable the chosen
inputs through the four gates using the CLCnGLS0 through CLCnGLS3 registers.
- 6.Select the gate
output polarities with the GyPOL bits.
- 7.Select the
desired logic function with the MODE bits.
- 8.Select the
desired polarity of the logic output with the POL bit. (This step may be combined with the previous
gate output polarity step).
- 9.If driving a
device pin, configure the associated pin PPS control register and also clear the
TRIS bit corresponding to that output.
- 10.Configure the
interrupts (optional). See CLC Interrupts.
- 11.Enable the CLC by
setting the EN bit.