74HC165 and 74HC595 using the same clk, stobe and data line.
by
Published on - 31st October 2021 08:54
We are using 3-pins for both 74HC165 and 74HC595.Thus we get multiple inputs and multiple outputs only over 3-pins.
Code:
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_ON & _BOREN_OFF & _CLKOUTEN_ON
__config _CONFIG2, _WRT_OFF & _PPS1WAY_OFF & _ZCDDIS_ON & _PLLEN_OFF & _STVREN_OFF & _BORV_LO & _LPBOR_OFF & _LVP_OFF
#ENDCONFIG
CLEAR
OSCCON = 1000
DEFINE OSC 4
'=================
' Set LCD Data port
DEFINE LCD_DREG PORTC
' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_DBIT 0
' Set LCD Register Select port
DEFINE LCD_RSREG PORTC
' Set LCD Register Select bit
DEFINE LCD_RSBIT 4
' Set LCD Enable port
DEFINE LCD_EREG PORTC
' Set LCD Enable bit
DEFINE LCD_EBIT 5
TRISA = 0
ANSELA = 0
LATA = 0
PORTA = 0
TRISC = 0
ANSELC = 0
LATC = 0
PORTC = 0
ADCON0 = 0
ADCON1 = 0
ADCON2 = 0
'FVRCON = 0
'CM1CON0 = 0
'CM1CON1 = 0
Clk VAR PORTA.0
Ltc VAR PORTA.1
Dat VAR PORTA.2
ByteIn VAR BYTE
ByteOut VAR BYTE
Index VAR BYTE
Timer VAR BYTE
Begin:
PAUSE 10
LCDOUT $fe,1,"Demo 165 & 595"
PAUSE 1000
LCDOUT $fe,1
ByteIn = 0
ByteOut = 0
Index = 0
Timer = 0
Start:
' 74HC165 part
ByteIn = 0
Ltc = 0
Ltc = 1
SHIFTIN Dat,Clk,0,[ByteIn] ' Here, Dat pin becomes an input pin.
' 74HC595 part (same for TPICB595)
ByteOut = 0
ByteOut.0[Index]=1
SHIFTOUT Dat,Clk,1, [ByteOut] ' Here, Dat pin becomes an output pin.
Ltc = 0
Ltc = 1
LCDOUT $fe,2, "ByteOut:",BIN8 ByteOut
LCDOUT $fe,$c0,"ByteIn :",BIN8 ByteIn
PAUSE 10
Timer = Timer + 1
IF Timer = 100 THEN ' Have 1000ms interval to swim through the bits of ByteOut
Timer = 0
Index = Index + 1 ' Swim through the bits.
IF Index = 8 THEN Index = 0
ENDIF
GOTO Start
END
Attached Files
Re: What is the dv/dt side of an inductor
Still, I'll reverse the pinout for the part in Kicad and add a comment; just to keep things clean.
Demon Today, 04:43I'd hate to use this part later and have EMI come and bite me in the asparagus.