The **74HC595** is a versatile 8-bit serial-in, parallel-out shift register with an 8-bit output latch. It features a three-state output for the parallel outputs. Data is shifted into the internal 8-bit shift register on the rising edge of the SCK (Serial Clock) signal, where it is then latched into the output buffer on the rising edge of the RCK (Register Clock) signal. The serial data input (SDA) is transferred into the shift register bit by bit, and once all 8 bits are loaded, the data is simultaneously output through the parallel pins.
---
;=========================================================
; 74HC595 Marquee Demonstration Program
;=========================================================
; Date of creation: 2007/08/12
; Creator: Give me a cigarette
;=========================================================
SDATA_595 EQU P1.0 ; Serial Data Input
SCLK_595 EQU P1.1 ; Shift Clock Pulse
RCK_595 EQU P1.2 ; Output Latch Control Pulse
;=========================================================
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
;---------------------------------------------------------
; Subroutine to output data to the latch
;---------------------------------------------------------
OUT_595:
LCALL WR_595
CLR RCK_595
NOP
NOP
SETB RCK_595 ; Rising edge triggers data transfer to output
NOP
NOP
NOP
CLR RCK_595
RET
;---------------------------------------------------------
; Subroutine to shift data into the shift register
;---------------------------------------------------------
WR_595:
MOV R4, #08H
MOV A, R0
WR_LOOP:
RLC A
MOV SDATA_595, C
SETB SCLK_595 ; Rising edge shifts data in
NOP
NOP
CLR SCLK_595
DJNZ R4, WR_LOOP
RET
;---------------------------------------------------------
; Delay subroutine for timing control
;---------------------------------------------------------
DELAY:
MOV R5, #03H
DEL0:
MOV R6, #0FFH
DEL1:
MOV R7, #0FFH
DJNZ R7, $
DJNZ R6, DEL1
DJNZ R5, DEL0
RET
;---------------------------------------------------------
END
---
This code demonstrates how to use the 74HC595 shift register to control a series of LEDs or other devices in a marquee-style display. By shifting data into the register and then latching it, we can create dynamic visual effects. The delay routine ensures that each bit shift and update happens at a visible rate, allowing for smooth transitions. This type of circuit is commonly used in LED displays, digital clocks, and other applications requiring multiple output signals from a limited number of microcontroller pins.
women's digital watch,ladies smart watch ,round women's smart watch,stylish women's smart watch
Dongguan Yingxin Technology Co., Ltd. , https://www.dgyingxintech.com