Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TI MSP430 Interrupt 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?

like image 697
TheDelChop Avatar asked Jan 23 '23 06:01

TheDelChop


2 Answers

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();
}
like image 181
Rex Logan Avatar answered Jan 24 '23 20:01

Rex Logan


Not really a "good" answer but why not make 2 separate interrupt handlers call the same function?

something like

__interrupt void Timer_A0_handler (void){
  Timer_Handler(0);
}
__interrupt void Timer_A1_handler (void){
  Timer_Handler(1);
}
void Timer_Handler(int which){
  if(which==1){
    ...
  }else{
    ...
  }
  ...
  ServiceWatchdogTimer();
}
like image 24
Earlz Avatar answered Jan 24 '23 19:01

Earlz