#include "2410addr.h"
#define LED1 (1<<5) // rGPB[5] =1 ; #define LED2 (1<<6) // rGPB[6] =1 ; #define LED3 (1<<7) // rGPB[7] =1 ; #define LED4 (1<<8) // rGPB[8] =1 ;
#define KEY1 (1<<1) // rGPF[1] =1 ; #define KEY2 (1<<4) // rGPF[4] =1 ; #define KEY3 (1<<2) // rGPF[2] =1 ; #define KEY4 (1<<0) // rGPF[0] =1 ;
void __irq IRQ_KEY(void){ ClearPending(BIT_EINT4_7); rEINTPEND = 0xffffff; rGPFUP = 0xf800; // KEY [7:0] => PU En rGPFCON=0xfcc0; //KEY[7:0] => INPUT; if ( !(rGPFDAT & KEY1) ) rGPBDAT=rGPBDAT & ~LED1; if ( !(rGPFDAT & KEY2) ) rGPBDAT=rGPBDAT & ~LED2; if ( !(rGPFDAT & KEY3) ) rGPBDAT=rGPBDAT & ~LED3; if ( !(rGPFDAT & KEY4) ) rGPBDAT=rGPBDAT & ~LED4; rGPFCON=0xfcc0; }
void EINT_Init(void){ //我这里的按键接口是 // k4-GPF0 -- 设置为中断应该是10 // k3-GPF2 -- 10 // k2-GPF4 -- 10 // k1-GPF1 -- 10 rGPFCON = 0xfeea;//111111 10 11 10 10 10
rEXTINT0 = 0x002092; //set eint0,1,2,4 falling edge interrupt // 0 010 000 010 010 010 pISR_EINT4_7 = (unsigned int)IRQ_KEY; rPRIORITY= 0x00000000; ClearPending(BIT_EINT4_7); rEINTPEND = 0xffffff; //clear interrupt flag rINTMOD=0x00000000; rINTMSK &= (~BIT_EINT4_7); rEINTMASK = 0x000fffe8;//enable EINT0,EINT1,EINT2,EINT4 //11...111 0 1 0 0 0 } void Main(void){ rGPBCON = 0x015550; rGPBUP = 0x7ff; rGPBDAT = 0xfff; EINT_Init(); while (1); }
我这程序错在哪里呢?怎么按键没反应,按k2就出现异常。其他键没什么反应。 |