![](http://datasheet.mmic.net.cn/370000/P9S12XEP100J1VVLR_datasheet_16728329/P9S12XEP100J1VVLR_715.png)
Chapter 18 Pulse-Width Modulator (S12PWM8B8CV1)
MC9S12XE-Family Reference Manual Rev. 1.07
Freescale Semiconductor
715
18.3.2.14 PWM Channel Duty Registers (PWMDTYx)
There is a dedicated duty register for each channel. The value in this register determines the duty of the
associated PWM channel. The duty value is compared to the counter and if it is equal to the counter value
a match occurs and the output changes state.
Thedutyregistersforeachchannelaredoublebufferedsothatiftheychangewhilethechannelisenabled,
the change will NOT take effect until one of the following occurs:
The effective period ends
The counter is written (counter resets to $00)
The channel is disabled
Inthisway,theoutputofthePWMwillalwaysbeeithertheolddutywaveformorthenewdutywaveform,
notsomevariationinbetween.Ifthechannelisnotenabled,thenwritestothedutyregisterwillgodirectly
to the latches as well as the buffer.
NOTE
Reads of this register return the most recent value written. Reads do not
necessarily return the value of the currently active duty due to the double
buffering scheme.
See
Section 18.4.2.3, “PWM Period and Duty”
for more information.
NOTE
Depending on the polarity bit, the duty registers will contain the count of
eitherthehightimeorthelowtime.Ifthepolaritybitisone,theoutputstarts
high and then goes low when the duty count is reached, so the duty registers
contain a count of the high time. If the polarity bit is zero, the output starts
low and then goes high when the duty count is reached, so the duty registers
contain a count of the low time.
To calculate the output duty cycle (high time as a% of period) for a particular channel:
Polarity = 0 (PPOL x =0)
Duty Cycle = [(PWMPERx-PWMDTYx)/PWMPERx] * 100%
Polarity = 1 (PPOLx = 1)
Duty Cycle = [PWMDTYx / PWMPERx] * 100%
For boundary case programming values, please refer to
Section 18.4.2.8, “PWM Boundary Cases”
.
Read: Anytime
Module Base + 0x001C = PWMDTY0, 0x001D = PWMDTY1, 0x001E = PWMDTY2, 0x001F = PWMDTY3
Module Base + 0x0020 = PWMDTY4, 0x0021 = PWMDTY5, 0x0022 = PWMDTY6, 0x0023 = PWMDTY7
7
6
5
4
3
2
1
0
R
W
Bit 7
6
5
4
3
2
1
Bit 0
Reset
1
1
1
1
1
1
1
1
Figure 18-16. PWM Channel Duty Registers (PWMDTYx)