Datasheet

Table Of Contents
2010 Microchip Technology Inc. DS39770C-page 161
PIC18F85J90 FAMILY
15.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 15-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 57
RCON IPEN
CM RI TO PD POR BOR 58
PIR1 ADIF RC1IF TX1IF SSPIF —TMR2IFTMR1IF 60
PIE1 ADIE RC1IE TX1IE SSPIE —TMR2IETMR1IE 60
IPR1
ADIP RC1IP TX1IP SSPIP —TMR2IPTMR1IP 60
TRISC TRISC7 TRISC6 TRISC5 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0 60
TRISE TRISE7 TRISE6 TRISE5 TRISE4 TRISE3 TRISE1 TRISE0 60
TRISG
SPIOD CCP2OD CCP1OD TRISG4 TRISG3 TRISG2 TRISG1 TRISG0 60
TMR2 Timer2 Register 58
PR2 Timer2 Period Register 58
T2CON
T2OUTPS3 T2OUTPS2 T2OUTPS1 T2OUTPS0 TMR2ON T2CKPS1 T2CKPS0 58
CCPR1L Capture/Compare/PWM Register 1 Low Byte 61
CCPR1H Capture/Compare/PWM Register 1 High Byte 61
CCP1CON
DC1B1 DC1B0 CCP1M3 CCP1M2 CCP1M1 CCP1M0 61
CCPR2L Capture/Compare/PWM Register 2 Low Byte 62
CCPR2H Capture/Compare/PWM Register 2 High Byte 61
CCP2CON
DC2B1 DC2B0 CCP2M3 CCP2M2 CCP2M1 CCP2M0 62
Legend: — = unimplemented, read as ‘0. Shaded cells are not used by PWM or Timer2.