2.4 Capture Mode Prescaler

There are four prescaler settings specified by the CCP Mode Select (MODE) bits where bits that determine which input edge triggers a Capture event. A Capture event can be configured to occur every:
  • 16th rising edge of the CCP input
  • 4th rising edge of the CCP input
  • Rising or falling edge of the CCP input
  • Edge (rising and falling) of the CCP input
Important: When capturing events on every edge (both rising and falling), the input trigger source must be operating at a frequency less than the instruction clock frequency and at least one instruction period must be between capture events. If the trigger source frequency is greater than the instruction clock frequency, a capture event may be missed, resulting in invalid data.

Whenever the CCP module is turned off, or the CCP module is not in Capture mode, the prescaler counter is cleared. Any Reset will clear the prescaler counter.

Switching from one capture prescaler to another does not clear the prescaler and may generate a false interrupt. To avoid this unexpected operation, turn the module off by clearing the CCPxCON register before changing the prescaler. Changing Between Capture Prescalers demonstrates the code to perform this function.

Changing Between Capture Prescalers

void UpdatePrescale(void)
{
    CCP1CONbits.EN = 0;               // Disable CCP
    CCP1CONbits.MODE = 0b0100;        // Update with new prescale
    CCP1CONbits.EN = 1;               // Re-enable CCP
}