|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区
您需要 登录 才可以下载或查看,没有账号?立即注册
×
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"
#define KEY1 (1<<0)
#define KEY2 (1<<3)
#define KEY3 (1<<5)
#define KEY4 (1<<6)
#define LED1 (1<<5)
#define LED2 (1<<6)
#define LED3 (1<<7)
#define LED4 (1<<8)
void IRQ_KEY(void)
{
rSRCPND&=(~(1<<5));
rINTPND&=(~(1<<5));
rEINTPEND&=(~((1<<8)|(1<<11)|(1<<13)|(1<<14)));
rGPGCON = rGPGCON & (~((3 << 0) | (3 << 6) | (3 << 10) | (3 << 12)));
if (rGPGDAT & KEY1){
rGPBDAT |= LED1;
}
else {
rGPBDAT &= ~LED1;
}
if (rGPGDAT & KEY2){
rGPBDAT |= LED2;
}
else {
rGPBDAT &= ~LED2;
}
if (rGPGDAT & KEY3){
rGPBDAT |= LED3;
}
else {
rGPBDAT &= ~LED3;
}
if (rGPGDAT & KEY4){
rGPBDAT |= LED4;
}
else {
rGPBDAT &= ~LED4;
}
rGPGCON |= (2 << 0) | (2 << 6) | (2 << 10) | (2 << 12);
}
void Main(void){
rGPBCON = (rGPBCON & 0xfffc03ff) | 0x15400;
rGPBDAT |= LED1 | LED2 | LED3 | LED4;
while (1);
}
void EINT_Init(void){
rGPGCON &= (~((3 <<0) | (3 <<6) | (3 << 10) | (3 << 12)));
rGPGCON |= (2 << 0) | (2 << 6) | (2 << 10) | (2 << 12);
rEXTINT1 = rEXTINT1 & (~((7 << 0) | (7 << 12) | (7 << 20) | (7 << 24)));
rEXTINT1 = rEXTINT1 | ((6 << 0) | (6 << 12) | (6 << 20) | (6 << 24));
pISR_EINT8_23 = (unsigned int)IRQ_KEY;
rPRIORITY = 0x7f; // 使用默认的固定的优先级
rINTMOD = 0x00000000; // 所有中断均为IRQ中断
rSRCPND&=(~(1<<5));
rINTPND&=(~(1<<5));
rEINTPEND&=(~((1<<8)|(1<<11)|(1<<13)|(1<<14)));
rINTMSK &= (~(1<<5)); // 使能外部中断8_23
rEINTMASK &= (~((1 << 8) | (1 << 11) | (1 << 13) | (1 << 14)));
}
程序MAKE后无错误提示,仿真运行后在板子上按键后LED没有反应,调试时GO后程序有时候会跳入一个死循环:33f01608 [0xeafffffe] dcd 0xeafffffe;
但有时候会在主程序断点停下来。
请教高手什么原因啊,是程序问题么?? |
|