English
Language : 

PIC16F707 Datasheet, PDF (135/284 Pages) Microchip Technology – 40/44-Pin, Flash Microcontrollers with nanoWatt XLP and mTouch™ Technology
PIC16F707/PIC16LF707
17.3.4 PWM RESOLUTION
The resolution determines the number of available duty
cycles for a given period. For example, a 10-bit resolution
will result in 1024 discrete duty cycles, whereas an 8-bit
resolution will result in 256 discrete duty cycles.
The maximum PWM resolution is 10 bits when PR2 is
255. The resolution is a function of the PR2 register
value as shown by Equation 17-4.
EQUATION 17-4: PWM RESOLUTION
Resolution = l--o---g------4---l-o--P-g---R---2-2-----+-----1------ bits
Note:
If the pulse width value is greater than the
period the assigned PWM pin(s) will
remain unchanged.
TABLE 17-5: EXAMPLE PWM FREQUENCIES AND RESOLUTIONS (FOSC = 20 MHz)
PWM Frequency
1.22 kHz 4.88 kHz 19.53 kHz 78.12 kHz 156.3 kHz
Timer Prescale (1, 4, 16)
PR2 Value
16
0xFF
4
0xFF
1
0xFF
1
0x3F
1
0x1F
Maximum Resolution (bits)
10
10
10
8
7
208.3 kHz
1
0x17
6.6
TABLE 17-6: EXAMPLE PWM FREQUENCIES AND RESOLUTIONS (FOSC = 8 MHz)
PWM Frequency
1.22 kHz 4.90 kHz 19.61 kHz 76.92 kHz 153.85 kHz
Timer Prescale (1, 4, 16)
PR2 Value
Maximum Resolution (bits)
16
0x65
8
4
0x65
8
1
0x65
8
1
0x19
6
1
0x0C
5
200.0 kHz
1
0x09
5
17.3.5 OPERATION IN SLEEP MODE
In Sleep mode, the TMR2 register will not increment
and the state of the module will not change. If the CCPx
pin is driving a value, it will continue to drive that value.
When the device wakes up, TMR2 will continue from its
previous state.
17.3.6 CHANGES IN SYSTEM CLOCK
FREQUENCY
The PWM frequency is derived from the system clock
frequency (FOSC). Any changes in the system clock fre-
quency will result in changes to the PWM frequency.
Refer to Section 7.0 “Oscillator Module” for
additional details.
17.3.7 EFFECTS OF RESET
Any Reset will force all ports to Input mode and the
CCP registers to their Reset states.
17.3.8 SETUP FOR PWM OPERATION
The following steps should be taken when configuring
the CCP module for PWM operation:
1. Disable the PWM pin (CCPx) output driver(s) by
setting the associated TRIS bit(s).
2. Load the PR2 register with the PWM period value.
3. Configure the CCP module for the PWM mode
by loading the CCPxCON register with the
appropriate values.
4. Load the CCPRxL register and the DCxBx bits of
the CCPxCON register, with the PWM duty cycle
value.
5. Configure and start Timer2:
• Clear the TMR2IF interrupt flag bit of the PIR1
register. See Note below.
• Configure the T2CKPS bits of the T2CON
register with the Timer2 prescale value.
• Enable Timer2 by setting the TMR2ON bit of
the T2CON register.
6. Enable PWM output pin:
• Wait until Timer2 overflows, TMR2IF bit of the
PIR1 register is set. See Note below.
• Enable the PWM pin (CCPx) output driver(s) by
clearing the associated TRIS bit(s).
Note:
In order to send a complete duty cycle and
period on the first PWM output, the above
steps must be included in the setup
sequence. If it is not critical to start with a
complete PWM signal on the first output,
then step 6 may be ignored.
 2010 Microchip Technology Inc.
Preliminary
DS41418A-page 135