© 2004 Microchip Technology Inc. DS70062C-page 15-19
Section 15. Motor Control PWM
Motor Control
PWM
15
Figure 15-3: PWM Period Buffer Updates in Free Running Count Mode
Figure 15-4: PWM Period Buffer Updates in Up/Down Counting Modes
The PWM period can be determined from the following formula:
Equation 15-1: PWM Period Calculation
Note: If the PWM time base is configured for one of the two up/down count modes, the
PWM period will be twice the value provided by Equation 15-1.
Old PTPER value
New PTPER value
Period value loaded from PTPER buffer register
New value written to PTPER buffer
PTMR Value
Old PTPER value
New PTPER value
New value written to PTPER buffer
PTMR Value
Period value loaded from PTPER Buffer register
PTPER =
F
PWM • (PTMR Prescaler)
F
CY
- 1
F
CY = 20 MHz
F
PWM = 20,000 Hz
PTMR Prescaler = 1:1
PTPER =
20,000 • 1
20,000,000
- 1
= 1000 -1
= 999
Example: