TI MSP430 中断源
我知道,当使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的问题的一般答案是否定的,没有直接的方法来检测当前正在调用哪个中断。然而,每个中断都有自己的中断标志,因此您可以检查中断中的每个标志。您应该使用启用标志来确保您正在处理实际被调用的中断。此外,对于 MSP430 上的定时器,还有矢量 TAIV,它可以告诉您在 A1 处理程序中要处理什么。 TAIV 的情况 0 是 A1 处理程序没有中断,因此对于这种情况,您可以假设它是 A0 处理程序。
我会做类似下面的事情。
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.
这并不是一个真正的“好”答案,但为什么不让 2 个独立的中断处理程序调用同一个函数呢?
类似的东西
Not really a "good" answer but why not make 2 separate interrupt handlers call the same function?
something like
查看 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.