ORG 0000H LJMP MAIN ORG 0003H LJMP INTRP0 ;INT0中断 ORG 000BH LJMP T0INT ;T0中断
ORG 0030H MAIN: MOV R0,#00H MOV SP,#05FH MOV PSW,#00H MOV TCON,#00H SETB IT0 ;INT0下降沿 SETB EX0 ;允许INT0 MOV TMOD,#01H ;T0为16位定时器 MOV TL0,#00H ;设定T0的定时初值,定时时间约为50ms(11.0592M晶振) MOV TH0,#04CH SETB ET0 ;允许T0中断 SETB PT0 ;T0为高优先级中断 SETB EA ;开中断 SETB TR0 ;启动T0 LOOP: MOV R0,#00H MOV TL0,#00H ;喂狗
MOV TH0,#04CH LJMP LOOP ; 返回LOOP
INTRP0:
ZHIXING:CLR P0.0 CGQ1PD: JNB P1.0,CGQ1 ;SENSOR1 SJMP CGQ1PD CGQ1: MOV 040H,#04H;DELAY 500MS QT1: MOV 041H,#0FFH DMS1: MOV 042H,#0FFH DJNZ 042H,$ DJNZ 041H,DMS1 DJNZ 040H,QT1
CLR P0.1 CGQ2PD: JNB P1.1,CGQ2;SENSOR2 SJMP CGQ2PD
CGQ2: MOV 043H,#04H;DELAY 500MS QT2: MOV 044H,#0FFH DMS2: MOV 045H,#0FFH DJNZ 045H,$ DJNZ 044H,DMS2 DJNZ 043H,QT2
CLR P0.2 CGQ3PD: JNB P1.2,CGQ3;SENSOR3 SJMP CGQ3PD CGQ3: MOV 046H,#04H;DELAY 500MS QT3: MOV 047H,#0FFH DMS3: MOV 048H,#0FFH DJNZ 048H,$ DJNZ 047H,DMS3 DJNZ 046H,QT3
CPL P0.2 SF1: MOV 049H,#02H;DELAY 250MS QT4: MOV 04AH,#0FFH DMS4: MOV 04BH,#0FFH DJNZ 04BH,$ DJNZ 04AH,DMS4 DJNZ 049H,QT4 JNB P1.2,SF1
CPL P0.1 SF2: MOV 04CH,#02H ;DELAY 250MS QT5: MOV 04DH,#0FFH DMS5: MOV 04EH,#0FFH DJNZ 04EH,$ DJNZ 04DH,DMS5 DJNZ 04CH,QT5 JNB P1.1,SF2
CPL P0.0 SF3: MOV 04FH,#02H ;DELAY 250MS QT6: MOV 050H,#0FFH DMS6: MOV 051H,#0FFH DJNZ 051H,$ DJNZ 050H,DMS6 DJNZ 04FH,QT6 JNB P1.0,SF3 RETI
T0INT: INC R0 CJNE R0,#0C8H,FANHUI;看门狗设定10s MOV R0,#00H SETB P0.0 SETB P0.1 SETB P0.2 CLR A PUSH ACC PUSH ACC FANHUI:RETI 在执行外部中断0时,如果保持p1口为高电平,使一直执行中断0,不退出。直到10s后,t0中断执行看门狗,但执行过看门狗后,再触发外部中断0,中断0中断不能执行,不知为什么?请个位老鸟们帮下忙
|