108
Pulse Width Modulation (PWM)
At present PWM hardware is a must for any microcontroller because in many cases, it is needed to
extract something more than ones and zeros from it. For example, consider the case of a sine wave
generator. Without the aid of a Digital-to-Analog Converter (DAC), generating sine waves seems
nearly impossible. However, we can still achieve that using Pulse Width Modulation (PWM) and some
mathematical tricks.
Generating waveforms, pulses with variable widths, patterns, sounds, communications pulses like
those in IR remotes, speed control, etc require PWM hardware. Keep in mind that all MSP30x2xxx
devices do not have any inbuilt DAC and so if analogue output is needed, we can use PWM with
necessary external RC filtering to create analogue output.
A few things must be observed before using MSP430 PWM hardware:
• Timer A PWMs are general purpose PWMs.
• There’s no separate option for dead-time.
• Maximum PWM resolution is 16-bit.
• CC Channel 0 is not like the other two channels. It has limited output options and in GRACE
you’ll notice that you can’t set PWM duty cycle.
• PWM frequency and resolution are interdependent.
• PWM pins are limitedly remappable.