DAT EQU 30H
SCANLED EQU 34H
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV SP,#5FH
MOV TMOD,#01H
MOV TH0,#HIGH(65536-5000)
MOV TL0,#LOW(65536-5000)
MOV SCANLED,#0
MOV 30H,#1
MOV 31H,#2
MOV 32H,#3
MOV 33H,#4
MOV R2,#0
CLR 00H
SETB EA
SETB ET0
SETB TR0
SJMP $
;--------------------
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-5000)
MOV TL0,#LOW(65536-5000)
SETB TR0
INC R2
CJNE R2,#200,T0CON
MOV R2,#0
CPL 00H
JB 00H,T0RD
MOV 30H,#1
MOV 31H,#2
MOV 32H,#3
MOV 33H,#4
SJMP T0CON
T0RD:
MOV 30H,#5
MOV 31H,#6
MOV 32H,#7
MOV 33H,#8
T0CON:
MOV DPTR,#LEDTAB
T000: ;数字显示
MOV R0,#DAT
MOV A,SCANLED
ADD A,R0
MOV R0,A
MOV A,SCANLED
JNZ T001
MOV P2,#01H
SJMP T0DIS
T001:
DEC A
JNZ T002
MOV P2,#02H
SJMP T0DIS
T002:
DEC A
JNZ T003
MOV P2,#04H
SJMP T0DIS
T003:
MOV P2,#08H
T0DIS:
MOV A,@R0
MOVC A,@A+DPTR
; CPL A
MOV P0,A
INC SCANLED
MOV A,SCANLED
ANL A,#03H
MOV SCANLED,A
RETI
;--------------------
LEDTAB:
DB 0C0H ;"0" 00H
DB 0F9H ;"1" 01H
DB 0A4H ;"2" 02H
DB 0B0H ;"3" 03H
DB 99H ;"4" 04H
DB 92H ;"5" 05H
DB 82H ;"6" 06H
DB 0F8H ;"7" 07H
DB 80H ;"8" 08H
DB 90H ;"9" 09H
;--------------------
END