Prerequisites and Tools
Chapter Topics
Timers .......................................................................................................................................... 6-1
Prerequisites and Tools ............................................................................................................ 6-2
Overview of MSP430 Timers .................................................................................................... 6-3
TIMER_A/B Nomenclature .................................................................................................... 6-4
Timer Summary ..................................................................................................................... 6-5
Timer Basics: How Timers Work ............................................................................................... 6-6
Counter.................................................................................................................................. 6-6
Frequency, Time-Period, Resolution ................................................................................ 6-7
Capture.................................................................................................................................. 6-8
Compare................................................................................................................................ 6-9
Timer Details: Configuring TIMER_A ...................................................................................... 6-12
1. Counter: TIMER_A_configure…() ................................................................................ 6-13
Timer Counting Modes .................................................................................................... 6-14
Summary of Timer Setup Code – Part 1 ......................................................................... 6-18
2a. Capture: TIMER_A_initCapture() ............................................................................... 6-19
2b. Compare: TIMER_A_initCompare() ............................................................................. 6-21
Summary of Timer Setup Code – Part 2 ......................................................................... 6-23
Output Modes .................................................................................................................. 6-24
PWM anyone? ................................................................................................................. 6-29
3. Clear Interrupt Flags and TIMER_A_startTimer() ........................................................... 6-30
4. Interrupt Code (Vector & ISR) ......................................................................................... 6-31
TIMER_A DriverLib Summary ................................................................................................. 6-32
Differences between Timer’s A and B ..................................................................................... 6-33
Lab Exercise ........................................................................................................................... 6-35
Prerequisites and Tools
To get full entitlement from this chapter, we expect that you are already familiar with
MSP430ware’s DriverLib as well as MSP430 clocking and interrupts. The “extra” piece of
hardware required for this chapter is a single jumper wire.
6 - 2 MSP430 Workshop - Timers