Lab 6a – Simple Timer Interrupt
5. Complete the code to for the 3
rd
part of the “Timer Setup Code”.
The third part of the timer setup code includes:
− Enable the interrupt (IE) … we don’t have to do this, since it’s done by the
TIMER_A_configureContinuousMode() function used in the previous question
− Clear the appropriate interrupt flag (IFG)
− Start the timer
// Clear the timer flag and start the timer
_______________________________________ ( TIMER_A0_BASE ); // Clear TA0IFG
_______________________________________ ( TIMER_A0_BASE,
// Start timer
TIMER_A_CONTINUOUS_MODE ); // in Continuous mode
6. Change the following interrupt code to toggle the Green LED when TimerA0 rolls-over.
Here’s the interrupt code that exists from our previous lab exercise, change it as needed:
#pragma vector=PORT1_VECTOR
__interrupt void pushbutton_ISR (void)
{
switch(__even_in_range( P1IV , 16 )) {
case 0: break; // No interrupt
case 2: break; // Pin 0
case 4: // Pin 1
GPIO_toggleOutputOnPin( GPIO_PORT_P1, GPIO_PIN0 );
break;
case 6: break; // Pin 2
case 8: break; // Pin 3
case 10: break; // Pin 4
case 12: break; // Pin 5
case 14: break; // Pin 6
case 16: break; // Pin 7
default: _never_executed();
}
}
Hint: On your Launchpad, what Port/Pin number does the Green LED use? ______________
Please verify your answers before moving onto the lab exercise.
MSP430 Workshop - Timers 6 - 39