单片机 > 单片机程序设计 > 详情

74HC595 的实际应用与编程

发布时间:2024-10-17 发布时间:
|

74HC595具有一个8位串行输入并行输出的移位寄存器和一个8位输出锁存器。 
;================================================
;74HC595 走马灯演示程序


;创作日期:2007/08/012
;创作者:  给我一支烟
;================================================

         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



『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
STC89C52RC单片机的NRF24L01无线通信程序.收发一体