;================================================
SDATA_595 EQU P1.0 ;串行数据输入
SCLK_595 EQU P1.1 ;移位时钟脉冲
RCK_595 EQU P1.2 ;输出锁存器控制脉冲
;================================================
ORG 0000H
LJMP MAIN
ORG 0030H
;================================================
MAIN:
MOV SP,#60H
MOV R0,#0FEH
MAIN1:
CALL OUT_595
CALL DELAY
MOV A,R0
RL A
MOV R0,A
JMP MAIN1
;---------------------------------------------------------------
;输出锁存器输出数据子程序
;---------------------------------------------------------------
OUT_595:
LCALL WR_595
CLR RCK_595
NOP
NOP
SETB RCK_595 ;上升沿将数据送到输出锁存器
NOP
NOP
NOP
CLR RCK_595
RET
;--------------------------------------------------------------
;移位寄存器接收数据子程序
;--------------------------------------------------------------
WR_595:
MOV R4,#08H
MOV A,R0
WR_LOOP:
RLC A
MOV SDATA_595,C
SETB SCLK_595 ;上升沿发生移位
NOP
NOP
CLR SCLK_595
DJNZ R4,WR_LOOP
RET
;--------------------------------------------------------------
;延时子程序
;--------------------------------------------------------------
DELAY:
MOV R5,#03H
DEL0:
MOV R6,#0FFH
DEL1:
MOV R7,#0FFH
DJNZ R7,$
DJNZ R6,DEL1
DJNZ R5,DEL0
RET
;---------------------------------------------------------------
END
相关文章