AJMP MAIN
ORG 000BH TO Time interrupt
lJMP T0INT
ORG 001BH T1 Count interrupt
LJMP T1CNT
ORG 030H
MAIN: MOV TMOD,#61H T1 count at MOD 2,T0 time int at MOD 1
MOV TL0,#0B0H 66536-50000=3CB0H 50000us=50ms=0.05s
MOV TH0,#3CH
SETB ET0 T0 interrupt enable
SETB TR0 T0 work
MOV TL1,#0FDH count num = 2
MOV TH1,#0FDH auto load 0FDH
SETB ET1
SETB TR1
SETB EA Enable all interrupt
MOV A,#28H 0.05s*40=2s
MOV P0,#0FEH
JMP $
ORG 060H
T0INT: CLR ET0 Disable T0 interrupt
CLR TF0 clr tf0
CPL P1.7
DEC A A--
JNZ T0RET A!=0 jmp
更改这里改灯闪烁
MOV A,P1
RR A
MOV P1,A
MOV A,#28H A==0A=40,
T0RET: SETB ET0 Enable interrupt
RETI
ORG 080H
当开关闭合时,三个LED同时亮灭闪烁运行,当开败渗关断开时,三个LED轮流点亮闪前颤烁运行,输察悔脊入口P1.3 P1.4 P2.3 开关P3.1while(1)
{
if(P3^1==0)
{ P1^3 =0P1^4 =0P2.3=0delay_ms(500)
P1^3 =1P1^4 =1P2.3=1delay_ms(500)
}
else
{
P1^3 =0delay_ms(500)
P1^3 =1P1^4 =0delay_ms(500)
P1^4 =1P2.3=0delay_ms(500)
P2.3=1P1^3 =0delay_ms(500)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)