OUTBIT EQU 0E101H;
CLK164 EQU 0E102H
DAT164 EQU 0E102H
IN EQU 0E103H
LEDBUF EQU 40H
ORG 0000H
MOV SP,#60H
MOV DPTR ,#0E100H
MOV A,#30H
MOVX @DPTR,A
MOV 40H,#00H
MOV 41H,#08H
MOV 42H,#03H
MOV 43H,#02H
LOOP1:MOV R5,#00H
LOOP2: MOV DPTR,#0B000H
MOV A,R5
MOVX @DPTR,A
MOV R0,#45H
MOV 45H,A
ACALL PTDS
MOV R6,#15H
DIR10:ACALL DISPLAY
DJNZ R6,DIR10
INC R5
CJNE R5,#00H,LOOP2
LOOP3:MOV DPTR,#0B000H
DEC R5
MOV A,R5
MOVX @DPTR,A
MOV R0,#45H
ACALL PTDS
MOV R6,#15H
DIR11:ACALL DISPLAY
DJNZ R6,DIR11
CJNE R5,#00H,LOOP3
SJMP LOOP1
DELAY:
MOV R7,#01
MOV R3,#01
DELAYLOOP:
DJNZ R3,DELAYLOOP
DJNZ R6,DELAYLOOP
RET
DISPLAY:SETB 0D3H
MOV R0,#LEDBUF
MOV R1,#6
MOV R2,#00100000B
LOOP:
MOV DPTR,#OUTBIT
MOV A,#00H
MOVX @DPTR,A
MOV A,@R0
MOV DPTR,#LEDMAP
MOVC A,@A+DPTR
MOV B,#8
DLP:
RLC A
MOV R3,A
MOV ACC.0,C
ANL A,#0FDH
MOV DPTR,#DAT164
MOVX @DPTR,A
MOV DPTR,#CLK164
ORL A,#03H
MOVX @DPTR,A
ANL A,#0FDH
MOVX @DPTR,A
MOV A,R3
DJNZ B,DLP
MOV DPTR,#OUTBIT
MOV A,R2
MOVX @DPTR,A
MOV R6,#01
CALL DELAY
MOV A,R2
RR A
MOV R2,A
INC R0
DJNZ R1,LOOP
MOV DPTR,#OUTBIT
MOV A,#0
MOVX @DPTR,A
CLR 0D3H
RET
LEDMAP:
DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H
DB 7FH,6FH,77H,7CH,39H,5EH,79H,71H
PTDS:MOV R1,A
ACALL PTDS1
MOV A,R1
SWAP A
PTDS1:ANL A,#0FH
MOV @R0,A
DEC R0
RET
DELAY1:MOV R7,#03H
SJMP DELAYLOOP
END
实验7 D/A转换实验
最新推荐文章于 2024-01-31 10:45:02 发布