PWM Datasheet
PWM Datasheet
7.0 TIMER2 MODULE Register 7-1 shows the Timer2 Control register.
Additional information on timer modules is available in
Timer2 is an 8-bit timer with a prescaler and a
the PICmicro® Mid-Range MCU Family Reference
postscaler. It can be used as the PWM time base for the
Manual (DS33023).
PWM mode of the CCP module(s). The TMR2 register
is readable and writable and is cleared on any device
Reset. FIGURE 7-1: TIMER2 BLOCK DIAGRAM
The input clock (FOSC/4) has a prescale option of Sets Flag
TMR2
bit TMR2IF Output(1)
1:1, 1:4 or 1:16, selected by control bits
T2CKPS1:T2CKPS0 (T2CON<1:0>).
Reset Prescaler
The Timer2 module has an 8-bit period register, PR2. TMR2 Reg
1:1, 1:4, 1:16
FOSC/4
Timer2 increments from 00h until it matches PR2 and
then resets to 00h on the next increment cycle. PR2 is Postscaler 2
Comparator
1:1 to 1:16 EQ
a readable and writable register. The PR2 register is T2CKPS1:
initialized to FFh upon Reset. 4 PR2 Reg T2CKPS0
to generate a TMR2 interrupt (latched in flag bit, Note 1: TMR2 register output can be software selected by the
TMR2IF (PIR1<1>)). SSP module as a baud clock.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
- n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
- n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
TMR1H TMR1L
CCP1CON<3:0>
Qs
EQUATION 8-1:
Duty Cycle
Resolution =
( FOSC
log FPWM ) bits
TMR2 = PR2 log(2)
TMR2 = Duty Cycle
Note: If the PWM duty cycle value is longer than
TMR2 = PR2
the PWM period, the CCP1 pin will not be
cleared.