我必须在其中禁用中断吗?
如果我在 Microchip C18 上使用多个中断,是否必须在一个中断内禁用高中断?
考虑下面的代码:
#ifndef OTHER_INTERRUPT_H
#pragma interrupt InterruptHook // interrupt fname
void InterruptHook(void)
{
#ifdef STEPPER_H
Stepper_Interrupt();
#endif
#ifdef FLOW_H
Flow_Interrupt();
#endif
}
#endif
我应该遵循下面代码中相同的方法吗? (然后我会将禁用功能放在函数内的适当位置。)
#ifndef OTHER_INTERRUPT_H
#pragma interrupt InterruptHook // interrupt fname
void InterruptHook(void)
{
#ifdef STEPPER_H
INTCONbits.GIEH = 0;
Stepper_Interrupt();
INTCONbits.GIEH = 1;
#endif
#ifdef FLOW_H
INTCONbits.GIEH = 0;
Flow_Interrupt();
INTCONbits.GIEH = 1;
#endif
}
#endif
Do I have to disable high interrupts while inside one, if I am using multiple interrupts on the Microchip C18?
Consider the code below:
#ifndef OTHER_INTERRUPT_H
#pragma interrupt InterruptHook // interrupt fname
void InterruptHook(void)
{
#ifdef STEPPER_H
Stepper_Interrupt();
#endif
#ifdef FLOW_H
Flow_Interrupt();
#endif
}
#endif
Should I follow the same approach as in the code here below? (I would then put the disables in appropriate places within the functions.)
#ifndef OTHER_INTERRUPT_H
#pragma interrupt InterruptHook // interrupt fname
void InterruptHook(void)
{
#ifdef STEPPER_H
INTCONbits.GIEH = 0;
Stepper_Interrupt();
INTCONbits.GIEH = 1;
#endif
#ifdef FLOW_H
INTCONbits.GIEH = 0;
Flow_Interrupt();
INTCONbits.GIEH = 1;
#endif
}
#endif
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于硬件。有些处理器在服务中断时会自动禁用中断。其他人则对中断进行优先级排序,以便在服务较低优先级的中断时仍然可以发生更高优先级的中断。
Microchip PIC18 系列微控制器具有多级硬件中断,并且它们也可以选择优先级。
It depends on the hardware. Some processors automatically disable interrupts while servicing one. Others prioritize their interrupts, so that a more high-priority interrupt can still occur while a lower is being serviced.
The Microchip PIC18 series microcontrollers feature multiple levels of hardware interrupts, and they can be optionally prioritized too.