中断实验终于做成了,最严重的错误在于如何判断某一位是1:应该用&而不是用 && 。害我调了好久。哎。。
可以参考的代码:int.tar.gz
//interrupt.c
#include "s3c2440.h"
void EINT_Handle()
{//interrupt handler.
unsigned long offset = INTOFFSET;
unsigned long eintPnd;
if(5 == offset){//EINT8~23
//it must use EINTPND to notify which interrupt it is.Because GPG mode is int not input
GPBDAT |= (0x3<<6); //led2 3 off
eintPnd = EINTPEND;
if(eintPnd & (1<<8)){//key1 press (在有外部中断发生的时候,也就是eintPnd不是0,如果用&&的话此条件永远为真)
GPBDAT &= ~(1<<6);
}
if(eintPnd & (1<<11)){//key2 press
GPBDAT &= ~(1<<7);
}
}
//clear the interrupt.
if(5 == offset)
EINTPEND =(1<<8) | (1<<11) ;
SRCPND = 1<<offset;
INTPND = 1<<offset;
}