一、设计任务
1、如图,单片机的P0口接在7SEG-MPX8上,P2.0~P2.3口接74LS138的A 、B、C口,Y0~Y7接在数码管位选的1~8上。用单片实现:数字1~8从数码管的最右边依次向左边移动,就像拉幕是一样。
二、电路原理图
图1:拉暮式数码显示数字1~~8
三、设计程序
//拉暮式显示数字1—8
DISP_CNT EQU 30H
TCNT
EQU 31H
ORG 00H
SJMP START
ORG 0BH
LJMP INT_T0
START: MOV DISP_CNT,#00H
MOV TCNT,#00H
MOV P2,#00H
MOV TMOD,#01H
MOV TH0,#(65536-5000)/256
MOV TL0,#(65536-5000)MOD 256
MOV IE,#82H
SETB TR0
DISP:
MOV A,DISP_CNT
MOV DPTR,#TABLE
MOV R0,P2
ADD A,R0
MOVC A,@A+DPTR
MOV P0,A
LJMP DISP
INT_T0:MOV TH0,#(65536-5000)/256
MOV TL0,#(65536-5000)MOD 256
INC P2
MOV A,P2
CJNE A,#08H,RETUNE
MOV P2,#00H
INC TCNT
MOV A,TCNT
CJNE A,#10,RETUNE
MOV TCNT,#00H
INC DISP_CNT
CJNE A,#15,RETUNE
MOV P2,#00H
MOV DISP_CNT,#00H
MOV TCNT,#00H
RETUNE:RETI
TABLE: DB 00H,00H,00H,00H,00H,00H,00H
DB 06H,5BH,4FH,66H,6DH,7DH,07H,7FH
DB 00H,00H,00H,00H,00H,00H,00H,00H
END
|