TI MSP430 中断源

发布于 2024-08-28 13:39:27 字数 273 浏览 24 评论 0原文

我知道,当使用 MSP430F2619 和 TI 的 CCSv4 时,我可以获得多个中断来使用相同的中断处理程序,其代码如下所示:

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

ServiceWatchdogTimer();
}

我的问题是,当我发现自己处于该中断中时,有没有一种方法可以找出这些中断中哪一个让我来到这里?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

無處可尋 2024-09-04 13:39:27

您的问题的一般答案是否定的,没有直接的方法来检测当前正在调用哪个中断。然而,每个中断都有自己的中断标志,因此您可以检查中断中的每个标志。您应该使用启用标志来确保您正在处理实际被调用的中断。此外,对于 MSP430 上的定时器,还有矢量 TAIV,它可以告诉您在 A1 处理程序中要处理什么。 TAIV 的情况 0 是 A1 处理程序没有中断,因此对于这种情况,您可以假设它是 A0 处理程序。

我会做类似下面的事情。

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

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();
}
愁杀 2024-09-04 13:39:27

这并不是一个真正的“好”答案,但为什么不让 2 个独立的中断处理程序调用同一个函数呢?

类似的东西

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

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();
}
妖妓 2024-09-04 13:39:27

查看 MSP430x1xx 系列用户指南,该设备似乎没有不要直接用该信息维护中断状态寄存器。您要么需要两个独立的中断向量,以便可以直接识别差异,要么需要查询两个设备以查看哪个设备需要服务。

如果您使用 2 个中断向量,它们当然可以调用或跳转(如果您使用汇编)到同一个例程来执行大部分工作,如 Earlz 给出的答案

请注意,芯片已经有一个中断向量表,因此要执行您在另一个答案中所做的评论中所说的内容,您只需将“未使用”中断的中断向量条目指向引发异常的例程一个错误。

Looking at the MSP430x1xx Family User's Guide, it looks like the device doesn't maintain a interrupt status register with that information directly. 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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文