|
最简单的按键中断控制led亮灭,调了将近两天还是出不来。求大神们拯救。
minni2440的板子
#include"2440addr.h"
#define U32 unsigned int
static void __irq Key_ISR(void);
delay()
{
volatile int i;
for(i=0;i<=0x10000;i++);
}
int main()
{
rINTPND=rINTPND;
rSRCPND=rSRCPND;
rINTMSK=0XFFFFdF;
rINTMOD=0;
rGPGCON &= ~(0x3<<0); /*set eint8 as interrupt*/
rGPGCON |= (0x2<<0);
rEXTINT1 &= ~(0xF<<0); //下降沿触发
rEXTINT1|=0X2;
rEINTPEND |= (1<<8); /*外部中断待定寄存器*/
rEINTMASK=0xfffeff; /*外部中断屏蔽寄存器*/
pISR_EINT8_23=(U32)Key_ISR;
rGPBCON|=0x400; //配置led1
rGPBCON&=~0x800;
rGPBDAT&=~0x20;
while(1);
}
static void __irq Key_ISR(void)
{
if(rEINTPEND&(1<<8))
{
rGPBDAT=~rGPBDAT; //led取反
rEINTPEND |= 1<< 8;
ClearPending(BIT_EINT8_23);
}
}
|
|