English
Language : 

PIC24FJ128GA Datasheet, PDF (115/232 Pages) Microchip Technology – General Purpose, 16-Bit Flash Microcontrollers
PIC24FJ128GA FAMILY
EXAMPLE 13-1: PWM PERIOD AND DUTY CYCLE CALCULATIONS(1)
1. Find the Period register value for a desired PWM frequency of 52.08 kHz, where FOSC = 8 MHz with PLL (32 MHz device
clock rate) and a Timer2 prescaler setting of 1:1.
TCY = 2/FOSC = 62.5 ns
PWM Period = 1/PWM Frequency = 1/52.08 kHz = 19.2 μs
PWM Period = (PR2 + 1) • TCY • (Timer 2 Prescale Value)
19.2 μs
= (PR2 + 1) • 62.5 ns • 1
PR2
= 306
2. Find the maximum resolution of the duty cycle that can be used with a 52.08 kHz frequency and a 32 MHz device clock rate:
PWM Resolution = log10(FCY/FPWM)/log102) bits
= (log10(16 MHz/52.08 kHz)/log102) bits
= 8.3 bits
Note 1: Based on TCY = FOSC/2, Doze mode and PLL are disabled.
TABLE 13-1: EXAMPLE PWM FREQUENCIES AND RESOLUTIONS AT 4 MIPS (FCY = 4 MHz)(1)
PWM Frequency
7.6 Hz
61 Hz
122 Hz 977 Hz 3.9 kHz 31.3 kHz 125 kHz
Timer Prescaler Ratio
8
1
1
1
Period Register Value
FFFFh FFFFh 7FFFh 0FFFh
Resolution (bits)
16
16
15
12
Note 1: Based on TCY = FOSC/2, Doze mode and PLL are disabled.
1
03FFh
10
1
007Fh
7
1
001Fh
5
TABLE 13-2: EXAMPLE PWM FREQUENCIES AND RESOLUTIONS AT 16 MIPS (FCY = 16 MHz)(1)
PWM Frequency
30.5 Hz 244 Hz 488 Hz 3.9 kHz 15.6 kHz 125 kHz 500 kHz
Timer Prescaler Ratio
8
1
1
1
Period Register Value
FFFFh FFFFh 7FFFh 0FFFh
Resolution (bits)
16
16
15
12
Note 1: Based on TCY = FOSC/2, Doze mode and PLL are disabled.
1
03FFh
10
1
007Fh
7
1
001Fh
5
FIGURE 13-1:
OUTPUT COMPARE MODULE BLOCK DIAGRAM
OCxRS(1)
Set Flag bit
OCxIF(1)
OCxR(1)
Comparator
Output
Logic
3
OCM2:OCM0
Mode Select
SQ
R
OCx(1)
Output Enable
OCFA or OCFB(2)
0 1 OCTSEL 0 1
16
16
TMR register inputs
from time bases
(see Note 3).
Period match signals
from time bases
(see Note 3).
Note 1: Where ‘x’ is shown, reference is made to the registers associated with the respective output compare channels 1 through 8.
2: OCFA pin controls OC1-OC4 channels. OCFB pin controls OC5-OC8 channels.
3: Each output compare channel can use one of two selectable time bases. Refer to the device data sheet for the time
bases associated with the module.
© 2006 Microchip Technology Inc.
Preliminary
DS39747C-page 113