利用单片机实现两位数码管显示功能。
求图和编程~ 展开
DAT EQU 30H
SCANLED EQU 32H
FSDAT EQU 33H
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV SP,#5FH
MOV TMOD,#01H
MOV TH0,#0F4H
MOV TL0,#048H
MOV P2,#00H
MOV SCANLED,#0
MOV 30H,#5
MOV 31H,#0
MOV FSDAT,#50
SETB EA
SETB ET0
SETB TR0
LOOP:
JB P3.0,LOOP1
JNB P3.0,$
INC FSDAT
MOV A,FSDAT
CJNE A,#100,LOOP01
LOOP01:
JC LOOP02
MOV FSDAT,#99
LOOP02:
MOV A,FSDAT
MOV B,#10
DIV AB
MOV 30H,A
MOV 31H,B
SJMP LOOP
LOOP1:
JB P3.1,LOOP2
JNB P3.1,$
MOV A,FSDAT
JZ LOOP11
DEC FSDAT
LOOP11:
MOV A,FSDAT
MOV B,#10
DIV AB
MOV 30H,A
MOV 31H,B
SJMP LOOP
LOOP2:
JB P3.2,LOOP
JNB P3.2,$
MOV FSDAT,#50
MOV 30H,#5
MOV 31H,#0
SJMP LOOP
;--------------------
T0ISR:
PUSH ACC
CLR TR0
MOV TH0,#0F4H
MOV TL0,#48H
SETB TR0
MOV DPTR,#LEDTAB1
T000:
MOV R0,#DAT
MOV A,SCANLED
ADD A,R0
MOV R0,A
MOV A,SCANLED
JNZ T001
MOV P2,#02H
SJMP T0DIS
T001:
MOV P2,#01H
T0DIS:
MOV A,@R0
MOVC A,@A+DPTR
CPL A
MOV P0,A
INC SCANLED
MOV A,SCANLED
ANL A,#01H
MOV SCANLED,A
POP ACC
RETI
;--------------------
LEDTAB1:
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
DB 88H ;"A" 0AH
DB 83H ;"B" 0BH
DB 0C6H ;"C" 0CH
DB 0A1H ;"D" 0DH
DB 86H ;"E" 0EH
DB 8EH ;"F" 0FH
DB 0FFH ;" " 10H
;--------------------
END
做好了,谢谢啦
好的
用52,是c语言,还没图~再画求帮助~