/////中断服务程序
void keyinthandler(void)
{
EXTINT = 1;
__disable_interrupt();
num++;
__enable_interrupt();
VICVectAddr = 0;
}
/////外部中断初始化
void key_init(void)
{
PINSEL0_bit.P0_1 = 3;
EXTMODE = 1;
EXTPOLAR = 0;
VICIntSelect &= ~(1<<VIC_EINT0);
VICVectAddr0 = (unsigned int)&keyinthandler;
VICVectCntl0 = 0x20 | VIC_EINT0;
EXTINT = 1;
VICIntEnable |= (1<<VIC_EINT0);
}
1 #pragma vector=IRQV
2 __irq __arm void irq_handler (void)
3 {
4 void (*interrupt_function)();
5 unsigned int vector;
6 vector = VICVectAddr; //获得中断向量.
7 interrupt_function = (void(*)())vector;
8 if(interrupt_function != NULL)
9 {
10 interrupt_function(); //调用向量中断函数.
11 }
12 else
13 {
14 VICVectAddr = 0; //清除VIC中的中断.
}
}
单步调试发现进入第二次中断 程序在6、8、10行循环执行 中断只执行了一次
这是什么原因?望各位高手帮忙解答 |