;16X16LED点阵流动显示
;逐列、逆向(低位开始)扫描
;====================================================================
SDATA_595_1 EQU P2.0 ;串行数据输入
SCLK_595_1 EQU P2.1 ;移位时钟脉冲
RCK_595_1 EQU P2.2 ;输出锁存器控制脉冲
SDATA_595_2 EQU P2.3 ;串行数据输入
SCLK_595_2 EQU P2.4 ;移位时钟脉冲
RCK_595_2 EQU P2.5 ;输出锁存器控制脉冲
ORG 0000H
AJMP MAIN
ORG 0030H
MAIN:MOV DPTR,#TAB ;字码表初址赋值
MOV R1,#00H ;列控制码
MOV R4,#96 ;移动“ ”及“单片机仿真”6个字符,共96列
CM: MOV R5,#5 ;每屏反复显示5次
MOV R3,#16 ;列数
C1: MOV R2,#0 ;取码指针
C16:MOV A,#00H
;MOV P2,#00H ;关显示
CLR P3.0
CALL OUT_595_1
CALL OUT_595_2
MOV A,R2
MOVC A,@A+DPTR ;取当前列显示字码的第一个字节
;MOV 60H,A ;送1~8行控制口
CALL OUT_595_1
INC R2
MOV A,R2
MOVC A,@A+DPTR ;取当前列的显示字码雀吵的第二个字节
;MOV 61H,A ;送9~15行控制口
CALL OUT_595_2
INC R2
MOV P1,R1 ;送列控制码
INC R1
ACALL D1MS ;显示2MS
ACALL D1MS
DJNZ R3,C16 ;一屏16列是否显示完
MOV R3,#16
DJNZ R5,C1 ;未显示5次,继续
INC DPTR ;一屏反复显示5次完,字码表初值加2
INC DPTR
DJNZ R4,CM ;96列未移动完银岁世,继续
AJMP MAIN ;96列移动完,返回,重新从“ ”开始显示
D1MS: MOV R6,#2
MOV R7,#248
锋肢 DJNZ R7,$
DJNZ R6,$-4
RET
;----------------------------------------------------------------------
;输出锁存器输出数据子程序
;----------------------------------------------------------------------
OUT_595_1:
LCALL WR_595_1
CLR RCK_595_1
NOP
NOP
SETB RCK_595_1 ;上升沿将数据送到输出锁存器
;NOP
;NOP
;CLR RCK_595_1
RET
;---------------------------------------------------------------------
;移位寄存器接收数据子程序
;---------------------------------------------------------------------
WR_595_1:
MOV R0,#08h ;
WR_LOOP_1:
CLR SCLK_595_1
RLC A
MOV SDATA_595_1,C
SETB SCLK_595_1 ;上升沿发生移位
DJNZ R0,WR_LOOP_1
RET
;----------------------------------------------------------------------
;输出锁存器输出数据子程序
;----------------------------------------------------------------------
OUT_595_2:
LCALL WR_595_2
CLR RCK_595_2
NOP
NOP
SETB RCK_595_2 ;上升沿将数据送到输出锁存器
;NOP
;NOP
;CLR RCK_595_1
RET
;---------------------------------------------------------------------
;移位寄存器接收数据子程序
;---------------------------------------------------------------------
WR_595_2:
MOV R0,#08h ;
WR_LOOP_2:
CLR SCLK_595_2
RLC A
MOV SDATA_595_2,C
SETB SCLK_595_2 ;上升沿发生移位
DJNZ R0,WR_LOOP_2
RET
TAB:
DB 000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ;
DB 000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ;" ",
DB 000H ,000H ,000H ,008H ,000H ,008H ,0E0H ,008H ,0F4H ,00DH ,054H ,005H ,0F4H ,07FH ,0F8H ,07FH ;
DB 01EH ,005H ,0FEH ,005H ,0FAH ,006H ,010H ,002H ,000H ,006H ,000H ,004H ,000H ,000H ,000H ,000H ;"单",0
DB 000H ,000H ,000H ,000H ,000H ,010H ,000H ,01CH ,0FCH ,00FH ,0FCH ,003H ,040H ,002H ,040H ,002H ;
DB 07EH ,07FH ,03EH ,07FH ,020H ,000H ,020H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ,000H ;"片",1
DB 000H ,008H ,040H ,00CH ,040H ,006H ,0DCH ,03FH ,0FEH ,03FH ,022H ,011H ,020H ,01DH ,0F0H ,00FH ;
DB 0F0H ,003H ,0F0H ,00FH ,0F0H ,01FH ,010H ,010H ,000H ,01CH ,000H ,01CH ,000H ,010H ,000H ,000H ;"机",2
DB 000H ,001H ,080H ,001H ,0C0H ,000H ,0F0H ,03FH ,0FCH ,03FH ,04CH ,018H ,040H ,00CH ,040H ,027H ;
DB 0CCH ,063H ,0ECH ,079H ,028H ,01FH ,020H ,007H ,020H ,000H ,020H ,000H ,000H ,000H ,000H ,000H ;"仿",3
DB 000H ,000H ,000H ,010H ,000H ,098H ,000H ,0C8H ,0E8H ,06FH ,0E8H ,03FH ,07CH ,01BH ,07EH ,00AH ;
DB 0E6H ,03FH ,0E4H ,07FH ,004H ,06CH ,000H ,004H ,000H ,004H ,000H ,000H ,000H ,000H ,000H ,000H ;"真",4
END