I have tried to interface a 16F628 with a 74HCT165 without success. I figured I should do a basic test to confirm that my code is working properly. I unplug the CK and PL pins and plug the Q7 pin on the PIC directly to power to test my code.
- when I plug Q7 to GND, I get all 0s, as expected.
- when I plug Q7 to +5V, I get all 0s and a 1 at the far right.
This is my code:
CMCON = 7
ASM
LIST
INCLUDE 'M16F62X.INC'
DEVICE PIC16F628, HS_OSC, WDT_ON, MCLR_OFF, PWRT_ON, LVP_OFF, PROTECT_OFF
XALL
NOLIST
ENDASM
INCLUDE "MODEDEFS.BAS"
TRISA = %10000000
TRISB = %00000001
DEFINE OSC 20
DEFINE SHIFT_PAUSEUS 3
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTA
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
DATAIN VAR BIT[16]
' ----- PORTB.0 = Q7 ----- PORTB.1 = CP ----- PORTB.2 = PL -----
PAUSE 500
LOW PORTB.2 : PAUSE 3
HIGH PORTB.2 : PAUSE 3
SHIFTIN PORTB.0,PORTB.1,MSBPRE,[DATAIN\16]
LCDOUT $FE,1,BIN16 DATAIN
END
Robert
![]()




Bookmarks