SPI v.s. I2C: What is the difference in 1way communication?

Hi,
I'm wondering what is the difference between SPI and I2C when I use them as 1way communication ( Master sends data to a slave)
Technically, I think there is no difference cus the way Master sends the data is the same.

Thank you

Much love

Nick Gammon’s discussion will answer most questions:

flow control in I2C comes from addresses: you send a message to 0x68, for example

flow control in SPI requires one pin per card. If you have 5 SPI cards you tie up 5 pins

Hi,
There is also the issue of transmission speed:

On I2C it is at most 400 KHz;

In SPI: REF: " Serial Peripheral Interface (SPI) - SparkFun Learn "
SPI can operate at extremely high speeds (millions of bytes per second), which may be too fast for some devices. To accommodate such devices, you can adjust the data rate. In the Arduino SPI library, the speed is set by the setClockDivider() function, which divides the controller clock (16MHz on most Arduinos) down to a frequency between 8MHz (/2) and 125kHz (/128).

Minor correction, which version of the I2C are you using. Per specification data on the I2C-bus can be transferred at rates of up to 100 kbit/s in the Standard-mode, up to 400 kbit/s in the Fast-mode, up to 1 Mbit/s in Fast-mode Plus, or up to 3.4 Mbit/s in the High-speed mode. You can have 127 addresses on the I2C bus, the number of devices connected to the bus is only limited by the total allowed bus capacitance of 400 pF. I hope this helps.

That is really addressing / device selection.
Flow control is when the receiver tells the sender to slow down or stop.
I2C does its device selection with no additional pins vs SPI needs a pin for each slave device.

I2C does support flow control. The slave can stretch the master's clock pulse to slow down or even stop the Master from clocking any more bits.
SPI doesn't have this capability.

--- bill

1 Like

Caution not all I2C devices support clock stretching (flow control). Here is some more information on that" Clock Stretching – I2C Bus". If any device or MCU on your I2C bus will possibly need to stretch the clock, you must check each device data sheet and confirm that the feature is supported. If they do not expect some very weird problems. The slaves stretch the clock, by holding it in the dominate state, the master is required to watch the clock and work accordingly. This is one of the reason for the pull up resistors and not active high drivers. Low is a dominate state and a high is a recessive state think an open collector or drain as the output. If the drivers were active high a fault would occur when another node tries to stretch the clock.

Only a master generates a clock, and all other devices have to work with that external clock. Consequently possible clock stretching problems only apply to an active master, not to any slave.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.