8XC196MC, MD, MH USER’S MANUAL
9-16
9.4.3 Specifying the Carrier Period and Duty Cycle
The reload register (WG_RELOAD) and the phase compare registers (WG_COMPx) control the
carrier period and duty cycle. Write a value to the reload register (Figure 9-10) to establish the
carrier period. Write a value to each phase compare register to specify the length of time that the
associated outputs will remain asserted.
WG_RELOAD
Address:
Reset State:
1FC8H
0000H
The waveform generator reload (WG_RELOAD) register and the phase compare registers
(WG_COMP
x
) control the carrier period and duty cycle. Write a value to the reload register to
establish the carrier period.
Changing the WG_RELOAD value changes both the carrier period and the duty cycle because the
outputs remain asserted for a constant length of time, while the counter takes longer to cycle. To
change the carrier period without changing the duty cycle, you must proportionally change both
WG_RELOAD and WG_COMP
x
at the same time, immediately after the interrupt.
15 0
Reload
Bit
Number
Function
15:0 Reload
This register determines the carrier period.
Use the following formulas to calculate carrier period and duty cycle.
where:
T
CARRIER
= carrier period, in µs
F
XTAL1
= input frequency on XTAL1 pin, in MHz
multiplier
= 4 for center-aligned modes; 2 for edge-aligned modes
WG_RELOAD = 16-bit WG_RELOAD value ≥ WG_COMP
x
WG_COMP
x
= 16-bit WG_COMP
x
value ≤ WG_RELOAD
Figure 9-10. Waveform Generator Reload (WG_RELOAD) Register
T
CARRIER
multiplier
WG_RELOAD×
F
XTAL1
--------------------------------------------------------------------
=
Duty Cycle
WG_COMPx
WG_RELOAD
--------------------------------------
100%×=