STC15F104E的外部中断工作异常
STC15F104E使用了外部中断,发现中断工作有时会失效,必需重新上电才能恢复,使用中不时会失效。
1 /******************************************************************* 2 INT0 or 1中断函数 3 *******************************************************************/ 4 #if(VER==1) 5 void exint1() interrupt 2 //INT1,interrupt 2 (location at0013H) 6 #endif 7 #if(VER==2) 8 void exint0() interrupt 0 //INT0,interrupt 0 (location at0003H) 9 #endif 10 {//static uchar CountTemp=0; // 11 // static bit flag_Hand=0; //标记用于手动开关在开的状态下灯灭,要点亮需再开关一次手动开关。 12 u8_CntTim001=0; 13 if(RelayCtl) 14 // if(DetInput) //read INT1(P3.3)port status,1:上升沿中断 0:下降沿中断 15 { RelayCtl=0; //关灯 16 flag_RelayState=RelayCtl; //存储继电器状态 17 18 flag_countdown_enable=0; //倒计时使能标志,0除能,1使能 19 flag_SetCouDownIndict=0; //倒计时开始指示,0指示关,1指示开,自动清0.【灭一下指示】 20 flag_HandCouDownIndict=1; //机械手动开关倒计时使能标志,0除能,1使能【为1时,HandSwitch_Cnt开始增1计数,为0时,清0】 21 } 22 else 23 { if((HandSwitch_Cnt<=2)&&flag_HandCouDownIndict) //0.25x4=1.0s 如果关灯时间在1.0s内又重新开灯时。//2020/12/03 改0.25x2=0.5s 24 { flag_countdown_enable=1; //倒计时使能标志,0除能,1使能【使能即进入倒计时】 25 flag_SetCouDownIndict=1; //自动关指示标置,0指示关,1指示开,自动清0. 【灭一下指示】 26 u8_CntTim101=0; 27 u8_CntTim102=0; //两计数提前清0 28 RelayCtl=1; 29 flag_RelayState=1; //存储继电器状态 30 DelayTimeSet(BUF_IAP2_ADDRESS_0); //设置延时关时间 31 } 32 else 33 { RelayCtl=1; //开灯 34 flag_RelayState=RelayCtl; //存储继电器状态 35 if(flag_SetCouDownType) //设置自动关类型标置==IapReadByte(IAP2_ADDRESS+1) //20190212 1使能,0除能 36 { flag_countdown_enable=1; //倒计时使能标志,0除能,1使能【使能即进入倒计时】 37 flag_SetCouDownIndict=0; //自动关指示标置,0指示关,1指示开,自动清0. 【灭一下指示】 38 u8_CntTim101=0; 39 u8_CntTim102=0; //两计数提前清0 40 RelayCtl=1; 41 flag_RelayState=1; //存储继电器状态 42 DelayTimeSet(BUF_IAP2_ADDRESS_0); //设置延时关时间 43 } 44 } 45 flag_HandCouDownIndict=0; //机械手动开关倒计时使能标志,0除能,1使能 【为1时,HandSwitch_Cnt开始增1计数,为0时,清0】 46 } 47 }
经查旧版Spec内有说明:A版本的外部中断有时会异常,建议不要使用,C版本的外部中断可正常使用。

最好使用新版本的芯片,如:STC15F104W、STC15W104,如不知芯片有Bug,使用过程中发现异常很让人抓狂。

浙公网安备 33010602011771号