Timer Details: Configuring TIMER_A
3. Clear Interrupt Flags and TIMER_A_startTimer()
Part 3 of our timer configuration code is for clearing the interrupt flags and starting the timer.
As described earlier in the workshop, you are not required to clear interrupt flags before enabling
an interrupt, but once again, this is common practice. In Part 3 of the example below, we first
clear the Timer flag (TA0IFG) using the function call provided by DriverLib. Then, we clear all the
CCR interrupts using a single function; notice that the “+” operator tells the function that we want
to clear both of these IFG bits.
We conclude the code for Part 3 by starting the timer. The start function only has two parameters:
• It’s probably obvious that you need to specify which timer that needs to be started.
• The other parameter specifies, once again, the count mode for the timer’s counter.
Warning!
Did we get your attention? The timer “start” function ended up being one of the biggest problems
during the development of this workshop.
As dumb as it sounds, we missed the fact that you need to set the counter mode (e.g. “UP”) in this
function. When we cut/pasted this function from another example, we never thought to change this
parameter.
Why, because we thought it had already been specified by using the TIMER_A_configureUpMode()
function. Well, we found out the hard way that you need to do both. Use the correct function AND
specify the correct count mode in the start function.
6 - 30 MSP430 Workshop - Timers