Difference between I2C and SPI

nsaspook

Joined Aug 27, 2009
16,322
It's mainly the physical wire distance but chip delays that cause phase delays have the same effect.

SPI is a full duplex interface so we must have synchronization at the master and returned slave data to the data clock. Wire distance causes phase delay so at what level that phase delay causes the returned slave data to lose synchronization depends on the speed (time between clock edges) of the transmission clock. You could drive a 100-m cable with SPI with the correct drivers and receivers but the speed would need to be reduced unless you split the slave data and clock into another receiver back at the master to eliminate round trip delay.

http://www.ti.com/lit/ug/tidued8/tidued8.pdf
 

Thread Starter

champ1

Joined Jun 4, 2018
136
It's mainly the physical wire distance but chip delays that cause phase delays have the same effect.
Thanks nsaspook so its cable length between master and slave device and we can determine maximum and minimum cable length for protocol.

Did you ever calculate distance how far master and slave should be connect. So far I have seen it at a very short distance.
 

WBahn

Joined Mar 31, 2012
32,832
I have followed this link https://aticleworld.com/difference-between-i2c-and-spi/ to understand difference between I2C and SPI

There is one point I2C is better for long distance and SPI is better for the short distance.

What is meaning of distance here, Is it the wire length between two devices or communication distance between two device ?
They are just different communications protocols, each with its own advantages and disadvantages. If you are designing a pure hardware interface (no programmable logic of any kind anywhere nearby) then SPI is very easy to implement while I²C is more difficult because of the need to perform collision detection and mitigation. But it becomes hard to manage as the number of devices grows since the master must decode a chip enable signal to each slave. I²C is easier to scale up, particularly from a wiring standpoint, but you have to have a means of assigning unique addresses to each device. Even though SPI (serial peripheral interface) and I2C (inter-integrated-circuit) were both intended for extremely short-distance comms, both have been used at reasonably long distances. I²C is the better choice as the distance grows because you don't have to deal so much with the phase delays in multiple lines, but you still have to account for propagation delays back and forth, particularly for doing proper collision detection.
 

Thread Starter

champ1

Joined Jun 4, 2018
136
I know hardware difference between I2C and SPI

I2C only uses 2 wires, Clock & Data; Clock is unidirectional and Data is bidirectional

SPI uses at minimum 4 wires, one Clock, one Data Out, one Data In, and one CS (chip select).

So I should use word like cable length instead of distance. Data transmission speed of communication protocols will depend on cable length between master and slave. if the cable length is longer, data transmission speed would be slower
 

shteii01

Joined Feb 19, 2010
4,644
I know hardware difference between I2C and SPI

I2C only uses 2 wires, Clock & Data; Clock is unidirectional and Data is bidirectional

SPI uses at minimum 4 wires, one Clock, one Data Out, one Data In, and one CS (chip select).

So I should use word like cable length instead of distance. Data transmission speed of communication protocols will depend on cable length between master and slave. if the cable length is longer, data transmission speed would be slower
Cable length is distance.

The trouble u r running in is cable routing. When u route a cable, u have to go around stuff and your cable length can increase greatly. That is why rs485 and other similar protocols were invented.
 
Top