Lab 6a – Simple Timer Interrupt
Setup the Timer
In this part of Lab 6, we will be setting up TimerA0 in Continuous Mode.
7. Add a new initTimers() function to main.c.
This requires three steps:
a) In main(), add a call to initTimers().
We recommend that you add the call below the initClocks() function call.
b) Add a prototype for the initTimers() function at the top of main.c.
c) Create an empty initTimers() function.
We recommend placing this below the initGPIO() function in main.c, though, you could
really put it anywhere inside the file. We’ll add the code to this function in the next step.
void initTimers(void) {
}
d) Build the code to make sure there are no syntax errors.
8. Add the code needed to setup the timer to the initTimers() function.
You may remember that the Timer setup code consisted of three parts. In this exercise,
though, we only use parts
and , since the Continuous mode does not require us to setup
a capture/compare register.
a) Configure the timer with a call to TIMER_A_configureContinuousMode().
Please refer to the Lab Worksheet for assistance. (Step 4, Page 6-38).
b) Add code to clear the interrupt flag, enable the interrupt, and start the timer.
Please refer to the Lab Worksheet for assistance. (Step 5, Page 6-39).
c) Build the code to make sure there are not syntax errors.
9. Modify the ISR to handle the TimerA0 interrupt, rather than GPIO port interrupt.
Please refer to the Lab Worksheet for assistance. (Step 6, Page 6-39).
10. Don’t forget to modify the “unused” vectors (unused_interrupts.c).
Failing to do this will generate a build error. (Most of us saw this error back during the lab
exercise for the Interrupts chapter.)
11. Build the code. Verify there are no syntax errors.
6 - 42 MSP430 Workshop - Timers