8XC196MC, MD, MH USER’S MANUAL
10-4
The counter counts down to 00H, at which time the PWM output is driven high, the counter value
is reloaded from the PWM_P ERIOD register, and the contents of the control registers are loaded
into the buffers. The PWM output remains high unti l the co u nter va lue ma tche s the val ue i n the
buffer, at which time the output is pulled low. You can read the count register (PWM_COUNT)
to see the current value of the counter. When the counter resets aga in (i.e., when an overflow oc-
curs) the output is switched high. (Loading PWMx_CONTROL with 00H forces the output to re-
main low.) Figure 10-2 shows typical PWM output waveforms.
NOTE
The PWMx_CONTROL register value and corresponding duty cycle result, in
Figure 10-2, are true only when the PWM_PERIOD register value is FFH.
Figure 10-2. PWM Output Waveforms
10.4 PROGRAMMING THE FREQUENCY AND PERIOD
The input frequency on XTAL1 (FXTAL1) and the contents of the PWM_PERIOD register deter-
mine the PWM output frequency (FPWM) and period (TPWM). Table 10-3 shows the PWM output
frequencies for common values of FXTAL1 with a variety of PWM_PERIOD values. Use the fol-
lowing formulas to calculate the PWM period value for the desired output frequency and write
the corresponding value to the PWM_PERIOD register.
TPWM (in µs) =
FPWM (in MHz) =
Duty
Cycle
0
0
0
0
0
PWM Control
Register Value
0% 00H
10% 19H
50% 80H
90% E6H
99.6% FFH
Output Waveform
A0119-02
512 (PWM_PERIOD 1)+×
FXTAL1
----------------------------------------------------------------------------
FXTAL1
512 (×PWM_PERIOD 1)+
----------------------------------------------------------------------------