Datasheet
2012 Microchip Technology Inc. DS30684A-page 183
PIC18(L)F2X/45K50
15.1.4 CCP PRESCALER
There are four prescaler settings specified by the
CCPxM<3:0> bits of the CCPxCON register. 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. Example 15-1 demonstrates
the code to perform this function.
EXAMPLE 15-1: CHANGING BETWEEN
CAPTURE PRESCALERS
15.1.5 CAPTURE DURING SLEEP
Capture mode requires a 16-bit TimerX module for use
as a time base. There are four options for driving the
16-bit TimerX module in Capture mode. It can be driven
by the system clock (F
OSC), the instruction clock (FOSC/
4), or by the external clock sources, the Secondary
Oscillator (S
OSC), or the TxCKI clock input. When the
16-bit TimerX resource is clocked by F
OSC or FOSC/4,
TimerX will not increment during Sleep. When the
device wakes from Sleep, TimerX will continue from its
previous state. Capture mode will operate during Sleep
when the 16-bit TimerX resource is clocked by one of
the external clock sources (S
OSC or the TxCKI pin).
#define NEW_CAPT_PS 0x06 //Capture
// Prescale 4th
... // rising edge
CCPxCON = 0; // Turn the CCP
// Module Off
CCPxCON = NEW_CAPT_PS; // Turn CCP module
// on with new
// prescale value