I want to be able to output correct data from the microcontroller to the 74HC595 shift register without using the clock lines separately. This schematic matches my ideas for 16 bits of data:
The micro I'm using is 8051 based (at89C2051).
If the RCK and SCK lines were connected to the microcontroller separately, then my code to send out the data would be as follows:
RCK equ P1.1
SCK equ P1.2
DATA equ P1.3
LOWBYTE equ 20h
HIGHBYTE equ 21h
clr SCK
clr RCK
mov A,HIGHBYTE
mov R1,#8h
send1:
rlc A
mov DATA,C
nop
setb SCK
nop
clr SCK
djnz R1,send1
mov A,LOWBYTE
mov R1,#8h
send2:
rlc A
mov DATA,C
nop
setb SCK
nop
clr SCK
djnz R1,send2
setb RCK
nop
clr RCK
But I don't have enough GPIO pins on my micro to allow for separate clock lines and I don't have enough board space for a larger micro. So I attempted code with the lines tied together as follows. Here, CK means all clocks tied together:
CK equ P1.2
DATA equ P1.3
LOWBYTE equ 20h
HIGHBYTE equ 21h
clr CK
mov A,HIGHBYTE
mov R1,#8h
send1:
rlc A
mov DATA,C
nop
setb CK
nop
clr CK
djnz R1,send1
mov A,LOWBYTE
mov R1,#8h
send2:
rlc A
mov DATA,C
nop
setb CK
nop
clr CK
djnz R1,send2
Somewhere, someone mentioned that the shift clock (SCK) is one ahead of the data latch clock (RCK) when they are tied and used together, but how do I apply this into my code and still ensure the correct 16-bits are sent on the shift register output lines?