TI MSP430 Interrupt source

TheDelChop picture TheDelChop · Apr 13, 2010 · Viewed 7.1k times · Source

I know that when working with the MSP430F2619 and TI's CCSv4, I can get more than one interrupt to use the same interrupt handler with code that looks something like this:

#pragma vector=TIMERA1_VECTOR
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void){

ServiceWatchdogTimer();
}

My question is, when I find myself in that interrupt, is there a way to figure out which one of these interrupts got me here?

Answer

Rex Logan picture Rex Logan · Apr 13, 2010

The general answer to your question is no there is no direct method to detect which interrupt is currently being called. However each interrupt has its own interrupt flag so you can check each flag in the interrupt. You should and the flag with the enable to make sure you are handling the interrupt that actually was called. Also with the timers on the MSP430 there is vector TAIV which can tell you what to handle in the A1 handler. Case 0 of the TAIV is that there was no interrupt for A1 handler so for that case you can assume it is the A0 handler.

I would do something like the following.

#pragma vector=TIMERA0_VECTOR
#pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A (void)
{
   switch (TAIV)         // Efficient switch-implementation
   {
     case  TAIV_NONE:          // TACCR0             TIMERA0_VECTOR
        break;
     case  TAIV_TACCR1:        // TACCR1             TIMERA1_VECTOR
        break;
     case  TAIV_TACCR2:        // TACCR2             TIMERA1_VECTOR
        break;
     case TBIV_TBIFG:          // Timer_A3 overflow  TIMERA1_VECTOR
        break;
     default;
        break;
   }
   ServiceWatchdogTimer();
}