interfacing SPI with 2 pins?


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2005
    Posts
    96

    Default interfacing SPI with 2 pins?

    I'm using a 16F877a on a project I am working on and the PCB is already complete and I have 2 GPIOs left over and I need to hook up a device that only has a SPI interface. Does anyone know of a good way of achieving this? I was thinking about trying to find a I2C to SPI bridge, but wanted to know if there way a better way. By the way I do have 5v and ground available as well.

    Thanks for any suggestions

  2. #2
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Is your processor a master or slave? You can't select a slave device, but you can combine the shift in/ shift out functions to use the same clock line and data pin. I did this for some PIC to PIC comms. The clock line rode high, when the master wanted to communicate, it would hold the clock line low until the slave pulled the data line low momentarily. Communications then commenced. The master was using PBP with shiftout, and the slave was using assembly for an on screen display. It worked great.

  3. #3
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    the pic16f877a would serve as the master in this case. I understand your suggestion and how it would work in pic to pic communications, but I am not sure if it will work with a slave SPI device. I'm trying to connect from the 877a to a Canbus controller MCP2515

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    modifyit,

    If you have an LCD in the device, you can multiplex the CLK and data lines with the data lines going to the display.

    Actually, if there are any devices in the circuit that are only active with an "Enable" input, then their data lines can be used as well.

    The only thing that can't be multiplexed are the CS/Enable pins themselves.
    <br>
    DT

  5. #5
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    I wish I had access to more pins, but all I readily have access to is GND,5V, and 2 GPIOs. I'm guessing it may just not be possible since I need to connect SI,SO,CS,and SCK to my SPI controller.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Then you're probably stuck with putting another PIC in there.

    Use something like a PIC16F630, and communicate serialy (2-pins), between the PIC's. Then the '630 can talk to the SPI device, with pins left over for other things if you need them.
    <br>
    DT

  7. #7
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    That's what I figured...thanks for the input

Similar Threads

  1. Using SPI with External Interrupts
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th June 2008, 04:08
  2. 16-bit SPI problem
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th June 2008, 15:42
  3. SPI Interfacing
    By toofastdave in forum Serial
    Replies: 8
    Last Post: - 18th November 2007, 11:15
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Timed pulses on 2 pins
    By Danie Joubert in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th March 2004, 07:38

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