Electrical – Open drain in I2C

i2copen-drain

In I2C, why SCK and SDA should be open drain? What will happen if they are not open drain. I am trying to implement I2C communication using bit banging. Should I enable Open drain circuitry of GPIO pins for SCk and SDA?
I am asking this may be because I dont know about open drain logic.

Best Answer

I²C is not a strict master-slave protocol (although your circuit might use it this way), but allows multiple masters, and allows slaves to delay transactions by clock stretching.

This means that multiple devices can drive the same signal line at the same time. And if two devices try to drive different levels, the result would be bus contention, which would not only make the actual level undefined, but also would form a short between VCC and GND which could burn out the output transistors of these devices.

In an open-drain system, if one device pulls the bus low while another device lets it float high, the result is a low signal. This is used by the I²C protocol to detect conflicts in a multi-master system, and to let the master detect when a slave pulls the clock low to delay it.

If you have only a single master, and if your slaves do not support clock stretching, you can use a push/pull output for the clock line. But the data line is written and read in the same transaction, so you must never actively drive it to the high level.

Related Topic