Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Outline
Introduction
PWM Definitions
Generation
Types
PWM on the HCS12
Applications
2
Introduction
Partial
Power
4
Duty Cycle - Introduction
On Off
VH
Duty
Cycle (D)
VL
Period (T)
5
Duty Cycle - Definition
On Off Duty Cycle is determined
VH by:
On Time
Duty Duty Cycle 100%
Cycle (D) Period
VL
Average signal can be
Period (T)
found as:
Vavg D VH 1 D VL
7
Types of PWM Left Aligned
On Off On Off
Vhi Vhi
Duty
Duty
Cycle
Cycle
~30%
Vlo ~60% Vlo
Period Period
8
Types of PWM Center Aligned
Vhi Vhi
Duty Duty
Cycle Cycle
~30% ~60%
Vlo Vlo
Period Period
9
Choosing PWM Frequency
Application dependant.
Not too low:
Audible frequencies
Twice the inverse of device time constant
10 Times higher than control system frequency
Not too high:
Transistors generate more heat at higher frequencies
Some loads will not respond at higher frequencies
10
Implementing PWM Using the
MC9S12C32
Dedicated PWM8B6C
Chip
6 Independent 8-bit
channels
3 Independent 16-bit
channels
Signal is outputted
through Port P
11
PWM8B6C Module
12
PWM8B6C Module - Other Features
Four source clocks (A, B, SA, SB) for a wide frequency range
Emergency shutdown
Some changes take a complete cycle to take effect
Modes of Operation:
Normal: everything is available
Wait: Low-power consumption and clock disabled
Freeze: Option to disable input clock
13
PWM8B6C Memory Map
Configured through specific
registers
Base address is defined at the
MCU level
Address offset is defined at
the module level
Register address = base
address + address offset
Registers are located from
$00E0 - $00FF
14
PWM Enable Register (PWME)
15
PWM Polarity Register (PWMPOL)
16
PWM Clock Select Register (PWMCLK)
17
PWM Prescaler Register (PWMPRCLK)
18
PWM Scale A Register (PWMSCLA)
Clock A Frequency
Clock SA Frequency
2 PWMSCLA
19
PWM Scale B Register
(PWMSCLB)
Clock B Frequency
Clock SB Frequency
2 PWMSCLB
20
PWM Control Register (PWMCTL)
22
PWM Period Register (PWMPERx)
23
PWM Duty Register (PWMDTYx)
25
Left vs. Center Aligned
Signal changes when counter is
equal to period register
In the center aligned mode, the
PWM counter goes from a down-
count to a up-count to down-
count, etc.
In the left aligned mode, the
PWM counter is a up-counter
and rests to zero when it
overflows
26
PWM Resolution
The true resolution depends on the value in PWMPERx even though
the PWM module is said to be 8-bit.
The number of distinct duty cycles equals the value stored in
PWMPERx.
Maximum number of distinct duty cycles is achieved by writing $FF to
the register PWMPERx so that it can represent 256 duty cycle states
(00, 01, 02, , to FF), which corresponds to 28=256 resolution.
27