|
- for (;;)
- {
- dwVal = rINTPND;
- if ((dwVal & MASK_BIT(21)) == 0)
- {
- continue;
- }
- //EXTINTPND 寄存器,判断是哪个外部中断触发
- dwVal = rEXTINTPND;
- if ((dwVal & MASK_BIT(EXTINT4)) != 0)
- {
- rEXTINTPND |= MASK_BIT(EXTINT4);
- //外部中断4 产生了,点亮LED1
- if(rPDATC & MASK_BIT(LED1))
- {
- sysUtilsLightLed (LED1, FALSE);
- printf("Turn off %s",leds[LED1 - 1]);
- }
- else
- {
- sysUtilsLightLed (LED1, TRUE);
- printf("Turn on %s",leds[LED1 - 1]);
- }
- printf(" *** rINTPND = %02X , rPDATC = %02X ***\n",rINTPND, rPDATC);
- sysUtilsDelay(10000000); //延时
- rEXTINTPND &= ~MASK_BIT(EXTINT4);//在这里清零
- rINTPND = 8; //还原rINTPND
- continue;
- }
- if ((dwVal & MASK_BIT(EXTINT5)) != 0)
- {
- //......
- }
- if ((dwVal & MASK_BIT(EXTINT6)) != 0)
- {
- //......
- }
- if ((dwVal & MASK_BIT(EXTINT7)) != 0)
- {
- rEXTINTPND |= MASK_BIT(EXTINT7);
- //外部中断7 产生了,点亮LED1,2,3
- sysUtilsLightLed (LED_ALL, FALSE);
- }
- //最后清除中断位
- rI_ISPC |= MASK_BIT(21);
- rI_ISPC = dwVal;
- }
复制代码
我用以上代码实现按键控制LED(按一次灯亮,再按一次灯熄灭),开始的时候灯不亮,按下按键,灯亮后进入sysUtilsDelay延时,但是延时完之后灯又熄灭了
是不是我代码有问题?
我用ARM7+S3C44B0X(SUMSUNG)
|
|