![](http://datasheet.mmic.net.cn/370000/P312XDP512F0VFV_datasheet_16728159/P312XDP512F0VFV_378.png)
Chapter 8 Pulse-Width Modulator (S12PWM8B8CV1)
MC9S12XDP512 Data Sheet, Rev. 2.17
378
Freescale Semiconductor
In this way, the output of the PWM will always be either the old waveform or the new waveform, not some
variation in between. If the channel is not enabled, then writes to the period register will go directly 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 period due to the double
buffering scheme.
See
Section 8.4.2.3, “PWM Period and Duty”
for more information.
To calculate the output period, take the selected clock source period for the channel of interest (A, B, SA,
or SB) and multiply it by the value in the period register for that channel:
Left aligned output (CAEx = 0)
PWMxPeriod=ChannelClockPeriod*PWMPERxCenterAlignedOutput(CAEx=1)
PWMx Period = Channel Clock Period * (2 * PWMPERx)
For boundary case programming values, please refer to
Section 8.4.2.8, “PWM Boundary Cases”
.
Read: Anytime
Write: Anytime
8.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.
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 8-15. PWM Channel Period Registers (PWMPERx)