(I am mainly from a software background and just started to work on an embedded platform. Excuse me if this is a naive question...)
I am planning to write a driver for an EEPROM which is connected to the MCU via an I2C bus. So I am reading a tutorial about the I2C bus.
The tutorial says:
Both SCL and SDA lines are "open drain" drivers. What this means is that the chip can drive its output low, but it cannot drive it high. For the line to be able to go high you must provide pull-up resistors to the 5v supply. There should be a resistor from the SCL line to the 5v line and another from the SDA line to the 5v line. You only need one set of pull-up resistors for the whole I2C bus, not for each device, as illustrated below:
The red part in the above image is added by me. I guess that's how the whole picture is.
My questions are:
- Is my adding of the red MCU correct?
- The bold part the chip is the red MCU, right?
- Why is it true that the chip cannot drive it high? Is it unable or forbidden to?
- What does open drain mean in plain English?
I searched a bit but seems cannot find a clear explanation...maybe an analogy will help.
Answer
Is my adding of the red MCU correct?
Not exactly. The MCU is just another member of the bus like the rest of the Devices. There is nothing particularly special about how the MCU operates on the I2C bus. The MCU can recognize when either line is high or low, and the MCU can pull on either (or both) of the lines itself in order to communicate with all the other devices on the bus.
The bold part the chip is the red MCU, right?
It implies that the MCU is somehow different than the other devices on the I2C bus. But in reality, it is NOT special.
Why the chip cannot drive it high?
If you understood the nature of passive pullup, open-drain busses, you would understand that is not a proper question. You don't WANT any of the devices to drive it high because that would completely preclude any communication on the bus. The devices can only communicate if they can pull the bus LOW so that all the other devices on the bus can recognize that activity is taking place.
What does the open drain mean in plain English?
It is just like the signaling system used on many pubic transportation vehicles. There is a long "rope" along the length of the car, and ANYONE along the line can pull down on the "rope" to signal that they want to get off at the next stop. If you fixed the "rope" so that it was always HIGH, then nobody could pull on it to signal a stop.
No comments:
Post a Comment