发布网友 发布时间:2024-10-13 18:11
共2个回答
热心网友 时间:2024-11-01 05:32
DISL EQU 30H
DISH EQU 31H
DAT EQU 33H
T0L EQU 38H
T0H EQU 39H
SCANLED EQU 3BH
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV SP,#5FH
MOV TMOD,#01H
MOV T0L,#0F0H
MOV T0H,#0D8H
MOV TH0,#0D8H
MOV TL0,#0F0H
MOV P2,#00H
MOV SCANLED,#0
MOV 33H,#10H
MOV 34H,#10H
MOV 35H,#10H
MOV 36H,#10H
MOV DISL,#0
MOV DISH,#0
SETB EA
SETB ET0
SETB TR0
SETB 00H
LOOP:
LCALL DELAY
JNB 00H,LOOP1
MOV A,DISL
ADD A,#01
MOV DISL,A
MOV A,DISH
ADDC A,#0
MOV DISH,A
LCALL DISCHG
LOOP1:
JB P3.0,LOOP2 ;显示1111
JNB P3.0,$
MOV DISL,#57H
MOV DISH,#04H
LCALL DISCHG
CLR 00H
SJMP LOOP
LOOP2:
JB P3.1,LOOP3 ;按一下减1
JNB P3.1,$
CLR 00H
MOV A,DISL
ORL A,DISH
JZ LOOP
CLR C
MOV A,DISL
SUBB A,#1
MOV DISL,A
MOV A,DISH
SUBB A,#0
MOV DISH,A
LCALL DISCHG
SJMP LOOP
LOOP3:
JB P3.2,LOOP ;恢复累加
JNB P3.2,$
SETB 00H
SJMP LOOP
;--------------------
DISCHG:
MOV R5,DISH
MOV R6,DISL
INC R5
CLR A
XCH A,R6
MOV B,#156
DISCHG1:
INC R6
ADD A,B
JC DISCHG1
DJNZ R5,DISCHG1
DEC R6
SUBB A,B
MOV B,#10
DIV AB
MOV 35H,A
MOV 36H,B
MOV A,R6
MOV B,#10
DIV AB
MOV 33H,A
MOV 34H,B
RET
;--------------------
T0ISR:
PUSH ACC
CLR TR0
MOV TH0,T0H
MOV TL0,T0L
SETB TR0
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
POP ACC
RETI
;--------------------
DELAY:
MOV R3,#200
DELAY1:
MOV R4,#250
DJNZ R4,$
DJNZ R3,DELAY1
RET
;--------------------
LEDTAB: DB 0FCH ;"0" 00H
DB 60H ;"1" 01H
DB 0DAH ;"2" 02H
DB 0F2H ;"3" 03H
DB 66H ;"4" 04H
DB 0B6H ;"5" 05H
DB 0BEH ;"6" 06H
DB 0E0H ;"7" 07H
DB 0FEH ;"8" 08H
DB 0F6H ;"9" 09H
DB 0EEH ;"A" 0AH
DB 3EH ;"B" 0BH
DB 9CH ;"C" 0CH
DB 7AH ;"D" 0DH
DB 9EH ;"E" 0EH
DB 8EH ;"F" 0FH
DB 00H ;" " 10H
;--------------------
END
热心网友 时间:2024-11-01 05:26
看 着急的你呀 单片机呀 你用啥显示的呀 液晶屏的程序能用到 led上吗?