下面是程序:
#include "..\config.h"
#define LED (1ul << 2)
#define LED_INIT() GPIO2DIR |= LED /* */
#define LEDOFF() GPIO2DATA |= LED /* */
#define LEDON() GPIO2DATA &= ~LED /* */
#define KEY (1ul << 1)
void myDelay (INT32U ulTime)
{
INT32U i;
i = 0;
while (ulTime--)
{
for (i = 0; i < 5000; i++);
}
}
void GPIOIsr (void)
{
GPIO0IC |= KEY; /* 清除中断标志 */
LEDON();
myDelay(400);
LEDOFF();
}
int main (void)
{
targetInit(); /* 初始化目标板,切勿删除 */
pinInit(); /* 引脚初始化 */
SYSAHBCLKCTRL |= (1ul << 6); /* 使能GPIO模块时钟 */
LED_INIT();
GPIO0DIR &= ~KEY; /* 设置P0.1为输入 */
GPIO0IS = 0x00; /* P0.1为边沿中断 */
GPIO0IEV = 0; /* 下降沿中断 */
GPIO0IE |= KEY; /* P0.1中断不屏蔽 */
zyIsrSet(NVIC_PIOINT0, (unsigned long)GPIOIsr, PRIO_ONE);
while (1) ;
}
按照例程“GPIO_KeyInterrupt”稍微修改了下,想通过PIO0_1接的按键进入中断(按键按下时引脚为低电平),但是一直没有成功,不知道有什么问题,麻烦各路大虾帮忙分析下,谢谢!