English
Language : 

MC68HC908LB8_05 Datasheet, PDF (110/234 Pages) Freescale Semiconductor, Inc – M68HC08 Microcontrollers
High Resolution PWM (HRP)
10.9 HRP Programming Examples
The HRP has been designed to simplify the software required to generate typical control waveforms and
reduce the CPU load.
The following examples show how to calculate the register values needed to generate the desired output
frequencies, resolutions, deadtime, etc. The examples consider only the case of variable frequency
mode, but the calculations for variable duty cycle mode are very similar.
Example 1
This example shows how to configure the module to output a frequency of 132.073 kHz, with an HRPCLK
of 8 MHz.
Period (seconds) = ------1---0----–--3------ = 7.57157 ¥ 10–6 = -P----[--1----0---:--0---]- + -I--N----T----⎝⎛----S--------T-2------E-S------E-P----L-----[[--2---4--:--0--:---]-0-------]--⎠⎞--
132.073
8 ¥ 106 -------3---2--------- ¥ 8 ¥ 106
2SEL[2:0]
(EQ 10-16)
P[10:0] + -I--N----T----⎝⎛----S--------T-2------E-S------E-P----L-----[[--2---4--:--0--:---]-0-------]--⎠⎞-- = 7.57157 ¥ 8 = 60.5725 = 60 + 0.5725
-------3---2---------
2SEL[2:0]
(EQ 10-17)
P[10:0] = 60 = $3C and I---N----T----⎝⎛---S---------T-2------E-S------E-P----L-----[[---2--4--:--0--:---]-0-------]--⎠⎞-- = 0.5725
-------3---2---------
2SEL[2:0]
(EQ 10-18)
If we use 32 steps, simplifying the last equation gives
S-----T---E----P-----[--4---:--0----] = 0.5725
32
(EQ 10-19)
Therefore, STEP[4:0] = 0.5725 ¥ 32 = 18.32 = 18 or 19
(EQ 10-20)
If we choose STEP[4:0] = 19, the output frequency = 132.026 kHz.
If we choose STEP[4:0] = 18, the output frequency = 132.094 kHz.
So STEP[4:0] = 19 gets us closer to our desired frequency of 132.073 kHz
In this case, the switching frequency is 132.094 kHz/32 = 4.1279 kHz.
MC68HC908LB8 Data Sheet, Rev. 1
110
Freescale Semiconductor