//-------------------------------------------------------------------------------
//端口1中断函数
//多中断中断源:P1IFG.0~P1IFG7
//进入中断后应首先判断中断源,退出中断前应清除中断标志,否则将再次引发中断
//-------------------------------------------------------------------------------
#pragma vector=PORT1_VECTOR
__interrupt void Port1()
{ uint8 IFG_temp = P1IFG; uint8 bit_num; for(uint8 i=0;i<8;i++) { if((IFG_temp & 0x01)==0x01) { if(i==0) bit_num = 0x01; else { bit_num = 2<<(i-1); } if(P1IES & bit_num) //进保护中断 { //处理Pi口上升沿中断 } else { //处理Pi口下降沿中断 } P1IFG &= ~bit_num; } IFG_temp >>=1; } LPM3_EXIT; //退出中断后退出低功耗模式。若退出中断后要保留低功耗模式,将本句屏蔽
} |