这个是程序
OE BIT P2.0
SI BIT P2.1
SCK BIT P2.2
RCK BIT P2.3
ORG 0000H
AJMP ledz
ORG 0030H
/*----------------------------------------------------------------------------
首屏左移程序
实现功能:从最右边开始向左移动,直到显示全屏
------------------------------------------------------------------------------*/
;1-8列左移
ledz: MOV DPTR,#TAB ;字型码表
MOV R5,#1 ;R5为74hc595移位次数
MOV R6,#8 ;R6为显示存储单元左八列
led0: MOV R3,0FFH ;帧扫描
led1: MOV R0,#0 ;R0为存储单元计数器
MOV R1,#0 ;R1为行扫描计数器
led2: ACALL ledz_s595 ;让595置1
MOV A,R0
MOVC A,@A+DPTR
ACALL ledz_595_1;调用移位寄存器74hc595左移1-8位
MOV A,#2
ADD A,R0
MOV R0,A
SETB OE ;关闭74hc595输出使能
CLR RCK ;装入74hc595二级缓存
SETB RCK
CLR RCK
MOV P1,R1 ;行计数R1送P1口送74LS154驱动led一行
CLR OE ;打开74hc595输出使能,显示
INC R1
CJNE R1,#16,led2 ;是否扫描完16行
DJNZ R3,led1 ;帧扫描完毕?
INC R5
DJNZ R6,led0 ;左八列是否完全显示?
;从右8列到16列
MOV R5,#1
MOV R6,#8
led3: MOV R3,#0FFH
led4: ACALL ledz_s595
MOV R0,#0
MOV R1,#0
led5:
ACALL ledz_s595 ;让595置1
MOV A,R0
MOVC A,@A+DPTR
ACALL ledz_595
INC R0
ACALL ledz_595_1
SETB OE
SETB RCK
CLR RCK
SETB RCK
MOV P1,R1 ;行计数R1送P1口送74LS154驱动led一行
CLR OE
INC R1
INC R0
CJNE R1,#16,led5
DJNZ R3,led4 ;帧扫描完毕?
DJNZ R6,led3 ;第一个字完全显示?
ACALL ledz ;重新开始
/*------------------------------------------------------------------------------
子程序
--------------------------------------------------------------------------------*/
ledz_595:
MOV R2,#8
loop8: RLC A
MOV SI,C
CLR SCK
SETB SCK
CLR SCK
DJNZ R2,loop8
RET
ledz_595_1:
RLC A
MOV SI,C
CLR SCK
SETB SCK
CLR SCK
DJNZ R5,ledz_595_1
RET
ledz_s595:
MOV A,0FFH
MOV R5,#1
RLC A
MOV SI,C
CLR SCK
SETB SCK
CLR SCK
CJNE R5,#16,ledz_s595
; 字型码数据表 -------------------------
TAB:
DB 0DFH,0FDH,0DFH,0FDH,00H,80H,0DFH,0FDH,17H,0FCH,0F7H,0D7H,10H,84H,0D7H,0F5H;
DB 0D3H,0B5H,14H,8CH,0FFH,0FFH,0EBH,0EEH,0DBH,0DDH,99H,99H,0BCH,0BBH,0FFH,0FFH;"燕"
END |