PIC16C926-I/CL Microchip Technology, PIC16C926-I/CL Datasheet - Page 59

no-image

PIC16C926-I/CL

Manufacturer Part Number
PIC16C926-I/CL
Description
64/68-Pin CMOS Microcontrollers with LCD Driver
Manufacturer
Microchip Technology
Datasheet
EQUATION 8-1:
At most, an 8-bit resolution duty cycle can be obtained
from a 31.25 kHz frequency and a 8 MHz oscillator, i.e.,
0 CCPR1L:CCP1CON<5:4> 255. Any value greater
than 255 will result in a 100% duty cycle.
In order to achieve higher resolution, the PWM fre-
quency must be decreased. In order to achieve higher
PWM frequency, the resolution must be decreased.
Table 8-2 lists example PWM frequencies and resolu-
tions for F
ues are also shown.
TABLE 8-2:
Timer Prescaler (1, 4, 16)
PR2 Value
Maximum Resolution (bits)
1.
2.
2001 Microchip Technology Inc.
Find the value of the PR2 register, given:
From the equation for PWM period in Section 8.3.1,
or
Find the maximum resolution of the duty cycle that can be used with a 31.25 kHz frequency and
8 MHz oscillator.
From the equation from maximum PWM resolution in Section 8.3.2,
or
• Desired PWM frequency = 31.25 kHz
• F
• TMR2 prescale = 1
1 / 31.25 kHz = [ (PR2) + 1 ] • 4 • 1/8 MHz • 1
32 s
PR2
PR2
1 / 31.25 kHz = 2
32 s
256
log(256)
8.0
OSC
OSC
PWM Frequency
= 8 MHz. TMR2 prescaler and PR2 val-
= 8 MHz
EXAMPLE PWM FREQUENCIES AND RESOLUTIONS AT 8 MHz
EXAMPLES OF PWM PERIOD AND DUTY CYCLE CALCULATION
= [ (PR2) + 1 ] • 4 • 125 ns • 1 = [ (PR2) + 1 ] • 0.5 s
= (32 s / 0.5 s) - 1
= 63
= 2
= 2
= (PWM Resolution) • log(2)
= PWM Resolution
PWM RESOLUTION
PWM RESOLUTION
PWM RESOLUTION
• 1 / 8 MHz • 1
• 125 ns • 1
488 Hz
0xFF
16
10
Preliminary
1.95 kHz
0xFF
10
4
8.3.3
The following steps should be taken when configuring
the CCP module for PWM operation:
1.
2.
3.
4.
5.
Set the PWM period by writing to the PR2
register.
Set the PWM duty cycle by writing to the
CCPR1L register and CCP1CON<5:4> bits.
Make the CCP1 pin an output by clearing the
TRISC<2> bit.
Set the TMR2 prescale value and enable Timer2
by writing to T2CON.
Configure the CCP module for PWM operation.
7.81 kHz
0xFF
10
1
SET-UP FOR PWM OPERATION
PIC16C925/926
31.25 kHz
0x3F
1
8
62.5 kHz
0x1F
1
7
DS39544A-page 57
250 kHz
0x07
1
5

Related parts for PIC16C926-I/CL