Datasheet

Table Of Contents
2010 Microchip Technology Inc. DS39933D-page 181
PIC18F87J90 FAMILY
16.4.3 SETUP FOR PWM OPERATION
The following steps should be taken when configuring
the CCP module for PWM operation:
1. Set the PWM period by writing to the PR2
register.
2. Set the PWM duty cycle by writing to the
CCPR2L register and CCP2CON<5:4> bits.
3. Make the CCP2 pin an output by clearing the
appropriate TRIS bit.
4. Set the TMR2 prescale value, then enable
Timer2 by writing to T2CON.
5. Configure the CCP2 module for PWM operation.
TABLE 16-5: REGISTERS ASSOCIATED WITH PWM AND TIMER2
Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reset
Values
on Page
INTCON GIE/GIEH PEIE/GIEL
TMR0IE INT0IE RBIE TMR0IF INT0IF RBIF 59
RCON IPEN
CM RI TO PD POR BOR 60
PIR1 ADIF RC1IF TX1IF SSPIF —TMR2IFTMR1IF 62
PIE1 ADIE RC1IE TX1IE SSPIE —TMR2IETMR1IE 62
IPR1
ADIP RC1IP TX1IP SSPIP —TMR2IPTMR1IP 62
TRISC TRISC7 TRISC6 TRISC5 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0 62
TRISE TRISE7 TRISE6 TRISE5 TRISE4 TRISE3 TRISE1 TRISE0 62
TRISG
SPIOD CCP2OD CCP1OD TRISG4 TRISG3 TRISG2 TRISG1 TRISG0 62
TMR2 Timer2 Register 60
PR2 Timer2 Period Register 60
T2CON
T2OUTPS3 T2OUTPS2 T2OUTPS1 T2OUTPS0 TMR2ON T2CKPS1 T2CKPS0 60
CCPR1L Capture/Compare/PWM Register 1 Low Byte 63
CCPR1H Capture/Compare/PWM Register 1 High Byte 63
CCP1CON
DC1B1 DC1B0 CCP1M3 CCP1M2 CCP1M1 CCP1M0 63
CCPR2L Capture/Compare/PWM Register 2 Low Byte 64
CCPR2H Capture/Compare/PWM Register 2 High Byte 63
CCP2CON
DC2B1 DC2B0 CCP2M3 CCP2M2 CCP2M1 CCP2M0 64
Legend: — = unimplemented, read as ‘0. Shaded cells are not used by PWM or Timer2.