Microchip Technology ARD00330 データシート

ページ / 480
 2010 Microchip Technology Inc.
Preliminary
DS39979A-page 165
PIC18F87J72 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
RCON
IPEN
CM
RI
TO
PD
POR
BOR
PIR1
ADIF
RC1IF
TX1IF
SSPIF
TMR2IF
TMR1IF
PIE1
ADIE
RC1IE
TX1IE
SSPIE
TMR2IE
TMR1IE
IPR1
ADIP
RC1IP
TX1IP
SSPIP
TMR2IP
TMR1IP
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
TRISE
TRISE7
TRISE6
TRISE5
TRISE4
TRISE3
TRISE1
TRISE0
TRISG
SPIOD
CCP2OD
CCP1OD
TRISG4
TRISG3
TRISG2
TRISG1
TRISG0
TMR2
Timer2 Register
PR2
Timer2 Period Register
T2CON
T2OUTPS3 T2OUTPS2 T2OUTPS1 T2OUTPS0 TMR2ON T2CKPS1 T2CKPS0
CCPR1L
Capture/Compare/PWM Register 1 Low Byte
CCPR1H
Capture/Compare/PWM Register 1 High Byte
CCP1CON
DC1B1
DC1B0
CCP1M3
CCP1M2 CCP1M1 CCP1M0
CCPR2L
Capture/Compare/PWM Register 2 Low Byte
CCPR2H
Capture/Compare/PWM Register 2 High Byte
CCP2CON
DC2B1
DC2B0
CCP2M3
CCP2M2 CCP2M1 CCP2M0
Legend: — = unimplemented, read as ‘0’. Shaded cells are not used by PWM or Timer2.