Shop OBEX P1 Docs P2 Docs Learn Events
Can propeller pins be shared for multiple SPI devices? — Parallax Forums

Can propeller pins be shared for multiple SPI devices?

twm47099twm47099 Posts: 867
edited 2015-01-11 18:06 in Propeller 1
Simple question - maybe?
If I am using a number of SPI devices that will be polled sequentially (for example 4 DS1600 digital thermometers) can the data and clock lines for each device be attached to the same prop pins with only the chip select (RESET in the case of the DS1600) being on separate prop pins?

I think that the data and clock signals would go out from the Prop to all the devices, but only the one whose chip select was active would be affected. Is that correct, or does each device require all three lines be connected to its own prop pins (3 pins per device vs 1 pin per device + 2 pins shared by all)?

Thanks
Tom

Comments

  • Heater.Heater. Posts: 21,230
    edited 2015-01-11 07:19
    Sounds like a good plan to me.
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-01-11 08:35
    Yep, I've done that several times. Once, on an industrial HVAC controller, we used an I2C IO expander, for the chip select lines and additional low-speed IO. Insead of have six chip selects, we used the EEPROM I2C buss. The only SPI pins used were for SCK, MOSI, and MISO.
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-01-11 08:43
    Can be shared, you just have to use dedicated nCS pins.

    You can take it one step further and use 3pins to select up to eight devices.
    3-to-8 decoder IC 74(A)HC138
    http://www.mouser.com/Search/Refine.aspx?N=1323043&Keyword=HC138&Ns=Pricing%7c0&FS=True

    2 to 4
    http://www.mouser.com/Search/Refine.aspx?N=1323043&Keyword=74LVC1G139&Ns=Pricing%7c0&FS=True
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-01-11 15:25
    I even use the clock and data from P28 and P29 (the EEPROM lines) as SCK and MOSI for SPI, why not? If an I2C device doesn't see its device address on the bus after a start condition it will ignore everything up till the next start condition. So it doesn't matter that the clock and data chatter away for SPI and usually the SPI clock rate is too high for I2C to work anyway. I use this scheme in conjunction with SD cards to save I/O.

    However this scheme would not work with using I2C as the chip selects, you need separate buses for that but you can just use I/O lines as chip selects or feed them into a demux for more chip selects. So if you use the I2C lines for SPI then you still need MISO and three other lines to a demux which means only 4 extra I/O on top of I2C to select 7 SPI devices (one for deselect) rather than the 4 I/O that would be wasted just on one SPI.

    In general I use I2C for most expect high-speed or high capacity memory etc.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-11 15:45
    The C3 uses a combination of chips (one of which tonyp12 linked to) to use a large number of SPI devices on relatively few I/O pins.
  • twm47099twm47099 Posts: 867
    edited 2015-01-11 16:26
    Thanks for all the info. I tried it using a DS1620 and MCP3208 and it worked well. Thanks again.

    Tom
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-11 18:06
    Duane Degn wrote: »
    The C3 uses a combination of chips (one of which tonyp12 linked to) to use a large number of SPI devices on relatively few I/O pins.
    This is true but one thing you have to be careful of is the SD card that shares the SPI pins. The problem is that the SD card does not come up in SPI mode. You have to switch it to SPI mode and until you do it can cause trouble for other SPI devices that share the same pins.
Sign In or Register to comment.