The CCP (Capture/Compare) module is a peripheral which uses TMR1/TMR2 as the time base to perform Capture/Compare/PWM operations. The Capture/Compare modes use TMR1 as time base, whereas PWM mode uses TMR2 as time base. The following table shows UTMR settings in different CCP modes:
CCP MODE[3:0] | CCP Mode | CCP Operation | UTMR Settings If START/RESET/STOP = <blank>, set based on use case |
Comments | |||
---|---|---|---|---|---|---|---|
START | RESET | STOP | Other | ||||
0001 |
Compare | Toggle output; clear TMR1 | — | At PR Match | — | — | Use OM = Pulse mode and OPOL to generate appropriate output. Set/Clear/Toggle output features are not available in UTMR. |
0010 |
Toggle output | — | — | — | — | ||
1000 |
Set output | — | — | — | — | ||
1001 |
Clear output | — | — | — | — | ||
1010 |
Pulse output | — | — | — | OM = Pulse output | — | |
1011 |
Pulse output; clear TMR1 | — | At PR Match | — | OM = Pulse output | — | |
0011 |
Capture | Every edge of CCPx input | — | — | Either ERS Edge | — | — |
0100 |
Every falling edge of CCPx input | — | — | Rising ERS Edge | EPOL = Inverted | — | |
0101 |
Every rising edge of CCPx input | — | — | — | — | ||
0110 |
Every 4th rising edge of CCPx input | — | — | — | Use CLC or NCO as a frequency divider and use that as ERS input. | ||
0111 |
Every 16th rising edge of CCPx input | — | — | — | |||
11xx |
PWM | PWM operation | Rising ERS Edge | At Start + PR Match | At PR Match |
OM = Level output OPOL = OPOL = |
UTMR requires a periodic ERS input to act as the PWM period. The PR value determines the PWM duty cycle. |