51单片机定时 汇编语言编写
发布网友
发布时间:2022-05-13 16:24
我来回答
共1个回答
热心网友
时间:2023-10-16 02:39
1:
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TH0,#HIGH(65536-10000) ;定时10毫秒
MOV TL0,#LOW(65536-10000)
SETB TR0
SETB ET0
SETB EA
LOOP:
INC A
SJMP LOOP
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-10000)
MOV TL0,#LOW(65536-10000)
SETB TR0
INC R2
RETI
END
2:
KEY BIT P1.0
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TH0,#HIGH(65536-50000) ;定时50毫秒
MOV TL0,#LOW(65536-50000)
SETB TR0
SETB ET0
SETB EA
CLR A
SJMP $
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
SETB TR0
JB KEY,T0E
MOV DPTR,#LEDTAB
PUSH ACC
MOVC A,@A+DPTR
MOV P0,A
POP ACC
INC A
MOV B,#10
DIV AB
T0E:
RETI
LEDTAB:
DB 00H,01H,02H,04H,08H,10H,20H,40H,80H,0FFH
END