Shop OBEX P1 Docs P2 Docs Learn Events
SPI / I2C pin sharing? — Parallax Forums

SPI / I2C pin sharing?

jazzedjazzed Posts: 11,803
edited 2011-03-22 19:28 in Propeller 1
What would be the consequences of having SPI data/clock share I2C data/clock pins?
Would the SPI protocol ever cause and I2C device to respond?

Haven't looked at this in detail, but it seems to have been a sub-topic in a thread last year.
The I2C pull-up resistor on SDA would cause some problems for SPI if it was too strong.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-03-22 18:27
    The SPI protocol could cause the I2C device to respond
  • BigFootBigFoot Posts: 259
    edited 2011-03-22 18:30
    I wouldn't mix the two, there is no telling what might happen :(...

    Why not use the Props I2C port as is, and use four other I/O pins for the SPI ?
  • jazzedjazzed Posts: 11,803
    edited 2011-03-22 18:56
    Thanks. Being lazy today. Prop pins are a scarce, precious resource.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-03-22 19:00
    You can share one of the pins, but not both. This is because you can hold the other pin so that nothing valid is seen. Typically, the CLK pin would be shared.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-22 19:04
    As long as SDA does not transition low while SCK is high, there should be no problem. An I2C transaction does not begin until SDA is pulled low while SCK is high. It ends when SDA goes high with SCK high. So, if SCK is pulled low first, while SDA is high, and SDA is changed only while SCK is low, you could actually use both lines for your SPI interface.

    -Phil
  • jazzedjazzed Posts: 11,803
    edited 2011-03-22 19:28
    As long as SDA does not transition low while SCK is high, there should be no problem. An I2C transaction does not begin until SDA is pulled low while SCK is high. It ends when SDA goes high with SCK high. So, if SCK is pulled low first, while SDA is high, and SDA is changed only while SCK is low, you could actually use both lines for your SPI interface.

    -Phil
    That's what I was looking for :-) Writing a SPI driver like that is probably painful and inefficient, but if it works that great :-)
    Still, I've pretty much settled on sharing the SCL pin. That way people don't get in trouble using any old SPI driver.
Sign In or Register to comment.