23.3 PWM Period

The PWM period is specified by the TxPR register. The PWM period can be calculated using the formula of Equation 23-1. It is required to have FOSC/4 as the selected clock input to the timer for correct PWM operation.

Equation 23-1. PWM Period
P W M P e r i o d = [ ( T 2 P R ) + 1 ] 4 T o s c ( T M R 2 Pr e s c a l e V a l u e )
Note: TOSC = 1/FOSC

When T2TMR is equal to T2PR, the following three events occur on the next increment cycle:

  • T2TMR is cleared
  • The PWM output is active (Exception: When the PWM duty cycle = 0%, the PWM output will remain inactive)
  • The PWMxDCH and PWMxDCL register values are latched onto the buffers
Important: The Timer2 postscaler has no effect on the PWM operation.