How do you interface a 74hc165 to a pic12f629


Closed Thread
Results 1 to 12 of 12
  1. #1
    orion1137's Avatar
    orion1137 Guest

    Question How do you interface a 74hc165 to a pic12f629

    Hello all im new to the pic basic so be easy on me. I am trying to interface a standard 74hc165 parallel to serial shift register to a pic 12f629 im using GPIO.0 as CLK OUT , GPIO.2 as the DATA INPUT pin and a push button to load the parallel inputs on the 74hc165 via the Serial Shift/ Parallel Load pin, I have a 8 bit dip switch connected to the parallel port of the 74hc165 with 4.7k pullups and ground when switch contact is closed. I have looked at the SERIN and HSERIN and just havent had any luck yet.

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    You need to use SHIFTIN.


    ---------------------------
    CMCON=7

    MyByte VAR Byte

    SHIFTIN GPIO.2,GPIO.0,0,[MyByte]
    ---------------------------

    I don't have a HC165 Datasheet available, make sure the mode matches the specs of the HC165.

    See PBP Manual Section 5.72
    Last edited by NavMicroSystems; - 6th March 2004 at 22:59.

  3. #3
    orion1137's Avatar
    orion1137 Guest


    Did you find this post helpful? Yes | No

    Smile Thanks !!

    Thank you!! Works like a charm. I got most of it from the Archives. Here is a cleaned up version.

    Low GPIO.0

    ' pin 1 of 74HC165 loads parallel port

    Pause 1

    High GPIO.0

    ' pin 1 of 74HC165 allow data to shift in

    ShiftIn GPIO.2,GPIO.1,0, [VAR1\8]

    'GPIO.2 to 74HC165 pin 9 and GPIO.1 to 74HC165 pin 2

    Pause 1

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,608


    Did you find this post helpful? Yes | No

    Default

    "I got most of it from the Archives."

    Is this on this forum?

    I SEARCHed and could not find any other reference to 74HC165.

    I am particularly interested in how the 74HC165 is wired.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,608


    Did you find this post helpful? Yes | No

    Default

    "See PBP Manual Section 5.72"

    I get SERIN2 in my copy...? SHIFT IN is over at 5.75.

    Robert
    :shrug:
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,608


    Did you find this post helpful? Yes | No

    Default

    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
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,608


    Did you find this post helpful? Yes | No

    Default

    Note: same results no matter what shift mode I use.

    I've cut out those lines of code to simplify reading on this forum, but I repeat the shift command 4 times using each mode and display 4 lines on the LCD.

    Robert


    Another note, I am chaining two 74HCT165s, hence 16 bits.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,608


    Did you find this post helpful? Yes | No

    Default

    Ok,

    I changed the data to a BYTE, reduced 16 in the shift and LCD commands down to 8 and my test signal worked.

    I don't see what it did not like about having 16 bits?

    Robert
    :shrug:
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,608


    Did you find this post helpful? Yes | No

    Default

    I added one step to my testing, adding a 2nd BYTE of data in the shift and LCD commands and the test signal works good too.

    So it likes 2 BYTES, but not 16 BITS, I can live with that...

    I think it was Ralph that said in the PIC-TO-PIC thread, "one thing at a time".

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  10. #10
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,608


    Did you find this post helpful? Yes | No

    Default

    Thank you Ralph and a HUMUNGOUS thank you to Mister E for his patience with a newb like me.

    Un gros bisou mon amour! :LOL:

    It works like a charm now, I can flick my bits like I want to.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Hehe... sti d'fif

    Great to know everything is working fine now.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,608


    Did you find this post helpful? Yes | No

    Default

    I'm going to write "74HCT166" in this thread, just so that the next guy that searches for that chip can find this thread.

    I started out using the 166, but the 165 is also good for my application. Maybe including the word here can save someone else the headaches I had trying to get the 166 to work.

    Robert


    Oh yeah, might as well include the other variants:

    74HC166
    74LS166
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. LCDOUT w/custom interface?
    By Mike, K8LH in forum PBP Extensions
    Replies: 4
    Last Post: - 3rd March 2015, 03:54
  2. Replies: 33
    Last Post: - 19th March 2010, 03:02
  3. 'SCI' interface
    By ecua64 in forum Off Topic
    Replies: 0
    Last Post: - 29th September 2005, 16:02
  4. PIC12F629, useing all I/O pins
    By Jcee324 in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 7th December 2004, 11:05
  5. User Configuration Interface in PBP
    By Radiance in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th February 2004, 08:00

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts