我用周工的ARM Executable Image for lpc2100模板,在ADS1.2中建了一个项目,然后添加如下文件main.c,模板其他文件未做任何改动. 该程序简单至极,仅仅测试EINT0中断响应并设置一个标志而已.我用示波器看到EINT0输入变低,在easy JTAG调试时也确实看到IRQstatus EINT0标志位起来了,可是程序就是进不了中断,奇怪死了.我后来用GPIO方式查询EINT0是完全没问题的. 下面是完整的main.c文件,请问哪里还需要设置一下呢?
#include "config.h"
unsigned int iIntHappened;
//EINT0 service void __irq IRQ_EINT0(void) { iIntHappened = 1; VICIntEnClr = 0x00004000; //关中断,待主程序循环中处理后再开启 }
//main program int main (void) {// add user source code unsigned int temp; //interrupt config temp = PINSEL1; temp &= 0x3bfffffc; temp |= 0x00000001; PINSEL1 = temp; //P0.16 作为中断输入 EXTMODE = 0x00000000; //EINT0 低电平有效 EXTPOLAR = 0x00000000; EXTINT = 0x0000000f; //清除此前可能的中断标志 VICIntSelect = 0x00000000; //all interrupt source as IRQ VICVectCntl0 = 0x2e; //EINT0 as IRQ slot0 VICVectAddr0 = (int)IRQ_EINT0; //EINT0 sservice address VICIntEnable = 0x00004000; //enable EINT0 //---------------------------------------------------------------- while(1) { if (iIntHappened) { iIntHappened = 0; VICIntEnable = 0x00004000; //再开启中断 } }
return 0; } |