Timer module

Using PWMs in Stellaris Launchpad

The Stellaris launchpad PWMs will be deceiving if you start the design by reading ‘Stellaris® Peripheral Driver Library’ instead of the “LM4F120H5QR” datasheet. You will assume that it has hardware PWMs and you will directly use the PWM APIs available in the driver library. Unfortunately this is not the case with the launchpad. It does not have seperate hardware PWM modules but it has timers which can be configured as PWMs. I will be explaining how to configure the PWM modules available in timer0 andtimer1 to drive the R,G,B LEDs available in the launchpad.


First thing you need to understand is the architecture of the Timer modules. These timer modules contain six 16/32 bit timers and six 32/64 bit timers. Each of these twelve timers can be further divided into two independent timers named as TimerA and TimerB. These can be configured to operate separately or can combine.

For example,
a 32 bit Timer0 has 16 bit Timer_A and 16 bit Timer_B,
a 64 bit Timer1 has 32 bit Timer_A and 32 bit Timer_B.
Refer to the Chapter 11 of the datasheet for more information.

Then you need to know what are the pins connected with the Launchpads LEDs and whether we can drive them using the PWM signals. If you refer to the Stellaris Launchpad Pinmaps, you will understand that PF_1, PF_2 and PF_3 will be respectively connected to RED, BLUE and GREEN LEDs.

Also if you refer to Table 11-1, Table 11-2 and Table 10-2 in the datasheet you will understand that
PF_1 can be driven through T0CCP1 (Timer 0 Timer B),
PF_2 can be driven through T1CCP0 (Timer 1 Timer A) and
PF_3 can be driven through T1CCP1 (Timre 1 Timer B).

That is all the hardware information you need to know. After that you need to go through the ‘Stellaris® Peripheral Driver Library’ to understand how to configure the Clocks, Timers and GPIO pins.