简体   繁体   English

TI MSP430中断源

[英]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: 我知道在使用MSP430F2619和TI的CCSv4时,我可以获得多个中断来使用相同的中断处理程序,其代码如下所示:

#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? 我的问题是,当我发现自己处于那个中断时,有没有办法弄清楚这些中断中的哪一个让我在这里?

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. 你应该和带有enable的标志一起确保你正在处理实际被调用的中断。 Also with the timers on the MSP430 there is vector TAIV which can tell you what to handle in the A1 handler. 还有MSP430上的定时器,有矢量TAIV,它可以告诉你在A1处理程序中要处理什么。 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. TAIV的情况0是A1处理程序没有中断,因此在这种情况下你可以假设它是A0处理程序。

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();
}

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();
}

Looking at the MSP430x1xx Family User's Guide , it looks like the device doesn't maintain a interrupt status register with that information directly. 查看MSP430x1xx系列用户指南 ,看起来设备没有直接使用该信息维护中断状态寄存器。 You'll either need to have 2 separate interrupts vectors so you can identify the difference directly, or you'll need to query both devices to see which needs service. 您需要有两个独立的中断向量,以便您可以直接识别差异,或者您需要查询两个设备以查看哪些需要服务。

If you use 2 interrupt vectors, they can certainly call or jump (if you're using assembly) to the same routine to perform the bulk of the work as in the answer given by Earlz . 如果你使用2个中断向量,他们当然可以调用或跳转(如果你正在使用程序集)到同一个例程来执行大部分工作,就像Earlz给出答案一样

Note that the chip has an an interrupt vector table already, so to do what you're talking about in the comment you made in another answer, you just have to point the interrupt vector entries for the 'unused' interrupts to the routine that throws an error. 请注意,芯片已经有一个中断向量表,所以要在另一个答案的注释中执行您所说的内容,您只需将“未使用”中断的中断向量条目指向抛出的例程即可。一个错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM