2

Without pull-up resistors connected to the 2 lines of I2C, I2C communication fails. Why is there a need to have pull-up resistors for I2C? In contrast, UART and SPI do not need pull-up resistors.

Another side question is how does one choose the value of the resistor?

user768421
  • 1,187
  • 6
  • 16
  • 28

3 Answers3

10

UART and SPI have dedicated push-pull drivers - this means there can be problems when two drivers are connected to the same line because the outputs "clash". The architecture of IIC is that drivers are open-collector (or open-drain) and they can only pull the line down. Because of this, resistors are used to pull the line back up when a driver chip is not active.

It's just the way it is on IIC.

Andy aka
  • 434,556
  • 28
  • 351
  • 777
6

I2C has some features that improve on other communication busses, and to implement that, it had to switch to a different style of connection. If two devices force a line to two different states, you can short the line and possibly damage something.

UARTs/Serial and SPI are uni-directional communication. By that I mean each line is dedicated in a single direction. You have a transmitting and a receiving pin. Since each pin is dedicated to that one direction, it can be controlled by one side without worry. Which leads to the second lacking trait in them, is that they are essentially single master. You have to have a dedicated bus for each UART, and for most practical purposes, each SPI master. Finally, there is no way to resolve conflicts on the bus, even if there is no damage if two devices try to talk on it.

I2C does not have these failings. It's open collector setup allows a single communication line to work in both directions, with multiple slaves. It can have multiple masters, since there is a built in way to check the line. A slave can hold the clock down (clock stretching) if it needs more time. A superset of I2C called SMBus allows even more features, like arbitrarily allowing a slave to signal or alarm.

In short I2C needs pull-ups as a design choice to allow multiple features missing from other communication buses, mainly to allow more communication on a single pair of wires

Passerby
  • 72,580
  • 7
  • 90
  • 202
1

Every I2C bus must be terminated

The I2C bus relies on open drain technology. Except for one special case in conjunction with the high speed mode no I2C device is allowed to drive the bus, i.e. to send a 1 by putting voltage on the bus. Instead, the bus is terminated to a high level, e.g. 5 V and both lines, SCL and SDA, remain there during idle mode. A device sends a 0 by pulling the bus to ground level. A 1 is sent by doing nothing, i.e. leaving the bus at high level. The termination of I2C lines is achieved by connecting the bus to the reference voltage of the bus over an appropriate resistor. Missing or wrong termination is the source of many field problems. As a rule of thumb, the higher the termination the better the signals. On the other hand a high termination bares a potential risk of damaging components. By the way, in I2C engineering terms a high termination means a strong pull-up to VCC which translates into a low value for the resistor.

Quote From: http://www.i2c-bus.org/termination/

GisMofx
  • 357
  • 5
  • 19