It was invented by Philips and now it is used by almost all major IC manufacturers. I2C bus is popular because it is simple to use, there can be more than one master, only upper bus speed is defined and only two wires with pull-up resistors are needed to connect almost unlimited number of I2C devices. Each slave device has a unique address. Transfer from and to master device is serial and it is split into 8-bit packets. All these simple requirements make it very simple to implement I2C interface even with cheap microcontrollers that have no special I2C hardware controller. The initial I2C specifications defined maximum clock frequency of kHz.
|Published (Last):||2 January 2017|
|PDF File Size:||18.15 Mb|
|ePub File Size:||9.86 Mb|
|Price:||Free* [*Free Regsitration Required]|
By Ashutosh Bhatt In embedded systems, a simple function rarely exists alone. A simple pushbutton and LEDs controller is useful but if that controller cannot report when a user has pressed a button or share the status its LED indicate, the controllers are not worth their value. Many embedded systems include peripheral devices connected to the microprocessor in order to expand its capabilities.
Data transmission between two these entities plays a major role in designing embedded systems. In general, the medium of data transmission can be either serial or parallel. All these peripheral devices interface with the microcontroller via a serial protocol.
Protocol is a language that defines the mode of communication between systems and devices like protocols specify the aspects of inter-device communications including bit ordering, bit pattern meanings, electrical and mechanical aspect. The key to increase the value is communication on a communication bus of choice for embedded systems of all sizes.
Philips Semiconductors presently, NXP Semiconductors has developed a two-wire bus protocol for inter-integrated circuit systems in , commonly known as I2C protocol. We, especially electronics design engineers have worked with this protocol in most of ourprojects.
It is a half-duplex bi-directional two-wire bus system for transmitting and receiving data between masters M and slaves S. Masters and Slaves play important role in I2C communication. Master is the one which initiates a communication, generates a clock and terminates the communication and Slave is the one which is handled by master and acts according to the master command.
It can also be possible that multiple masters can communicate with multiple slaves. As we know, the bus consists of SCL and SDA line, SCL serial clock line is responsible for synchronizing the communication and is controlled by Master the slave can also control the clock line, we will discuss about this topic later and SDA serial data line is responsible for providing the data bi-directionally and can be used by master or slave or both.
There are mainly four modes which define the data rate of the I2C communication system: Fig. The first chip on UART was designed in around It requires a minimum of two pins transmitter and receiver pin and a common ground line for data communication.
The UART chip is generally found inbuilt in most of the microcontrollers. As only two devices can communicate with each other over a UART bus, it is not well suited for multiple devices communication. The highest data rate UART can support is kbps— kbps which was still a low speed as per the requirements. It has only three lines i. It is a full duplex serial data communication process. SPI can be used for multiple device communication. SPI is a single-master multi-slave protocol, it cannot support multiple masters communicating with multiple slaves.
This broughtI2Cto the picture which have all the desired features of a multi-bus communication. In TWI, the serial data transmission is done in asynchronous mode. This protocol uses only two wires for communicating between two or more ICs.
In the whole tutorial, we will deal with the master, slave, transmitter and receiver. Half Duplex Communication—I2C is a half-duplex communication meaning in transmission or reception of data between two devices, only one type of communication can be established at a time. The bus can perform either read or write operation at a single time. In , it was announced that I2C could support a data rate of KHz with bit addressing, this has increased the number of devices support on the bus.
Currently, bit addressing is not much popular in use. A device is only able to pull the bus line to go low in a conductive state; it cannot drive the line high. This is called open-drain or open collector mechanism. Open-drain refers to a type of output at the collector or drain that can drive the corresponding line to go low voltage generally ground but cannot drive the line to a high voltage. So, we need to add pull-up resistors on the line so that when drivers are in idle condition, they must not be floating and can restore the signal to default high in the non-conductive state.
Thus, no device may force a high on a line because the bus lines are active low , this means that the bus will never run into a communication issue where one device may try to transmit a high, and another transmits a low, causing a short power rail to ground.
In general, we can take a value between 4kk ohm. Because when one master in multi-master environment drives the bus line to go from high to low but when it sees that the line is already low because some other master is using the line, it halts its communication and waits for the completion of the line to go in the idle state. This is another benefit of the I2C protocol. This section will take a closer look on how they actually work in a protocol.
It was created by NXP Semiconductors, originally a Phillips semiconductor division, to attach slow speed peripheral devices to the embedded microprocessor. It is used for low to medium data rate communication. In TWI the serial data transmission is done in asynchronous mode.
I2C is a Multi-point protocol in which a maximum up-to peripheral devices can be connected to communicate along the serial interface which is composed of a bi-directional line SDA and a bi-directional serial clock SCL. The bus consists of just two wires or circuit traces, one for clock and the other for data, with a pull-up resistor on each wire of the bus. One of the two devices, which control the whole process, is known as Master and the other which responds to the queries of master is known as Slave device.
SCL is the clock line bus used for synchronization and is controlled by the master. SDA is known as the data transfer bus. Figure below shows a typical arrangement of I2C. When idle, both lines are high. Releasing SDA to float high again would be a stop marker, signaling the end of a bus transaction.
The only external hardware needed to implement the bus is a single pull-up resistor for each of the TWI bus lines. All devices connected to the bus have unique address. The TWI bus is a multi-master bus where one or more devices, capable of taking control of the bus, can be connected. The master supplies the clock; it initiates and terminates transactions and the intended slave based upon the address provided by the master acknowledges the master by driving or releasing the bus.
Addressing opens the lines of communication between the master and its intended slave device and the master keeps the connection open until it wishes to terminate the connection when the master is finished with the slave. The status codes are divided in Master and Slave codes and further in receive and transmit related codes.
Status codes for Bus Error and Idle also exist. Once decided which device will act as master the data transmission takes place. Data transfer is always initiated by a Bus Master device. If the Master does not receive any acknowledgement the transfer is terminated. The receiving device then acknowledges the data. If a Slave device cannot handle incoming data until it has performed some other function, it can hold SCL low to force the Master into a wait-state.
All data packets transmitted on the TWI bus are 9 bits long, consisting of one data byte and an acknowledge bit. Upon an address match, the Control Unit is informed, allowing correct action to be taken. During data transfer the two wire data register contains the address or data bytes to be transmitted or received. If the TWI has initiated a transmission as Master, the Arbitration Detection hardware continuously monitors the transmission trying to determine if arbitration is in process by synchronizing with Address match unit.
Arbitration is a technique which allows to ensure that no two microcontrollers tries to send data at the same time. Correct action can then be taken and appropriate status codes generated. This can due to the physical characteristics of the bus easily be detected.
If one device pulls a line low, the others cannot transmit high. When a device has lost arbitration, it must stop transmitting and wait until the next STOP condition before trying to take control of the bus again. In order to avoid false marker detection, the level on SDA is changed on the negative edge and is captured on the positive edge of SCL.
There can be multi master or single master mode of communication. The status values are the predefined values and cover the different states that the TWI can be in after every operation of data transfer.
Error detection or the faulty transmission can be detected by looking at the status values. The start condition is followed by seven bit slave address and then by a data direction bits. Every slave is recognized by its address The slave address is assigned to slave device at the time of slave initialization.
If the data direction bit is logic zero the master performs write operation with slave or if the data direction bit is logic one then the master performs read operation from slave. Receiving device then acknowledges the data. The acknowledgement signal updates the status register. There are various stages in completing the communication between master and slave devices. And we are taking 7-bit addresses space for the slaves. There are basically two operations involved in the communication process: 1.
Transmission of data from Master to Slave 2. Reception of data from Slave to Master E. I2C displays are the example in which master transmits the data to the slave to display it on the screen. Temperature or motion sensors are the example where master takes the required data from the slave and process it.
Note: Below, We will talk about the addresses of the device. For better understanding, we can take any I2C device e. BMA and go through the datasheet. Steps involve for writing the data from Master to Slave: Address- , Register Address — 1.
Then sends the 7-bit unique address of the desired slave with the write operation command set to 0. All connected slaves listen to the address and matched slave responses with ACK byte set.
For successful acknowledgement, it sends the required internal 8-bit register address of the slave to which data needs to be written. Master again waits for the acknowledgement. For successful acknowledgement, write the 8-bit data to the slave.
Changing contrast, hue, and color balance settings in monitors via Display Data Channel. Changing sound volume in intelligent speakers. Controlling small e. Reading hardware monitors and diagnostic sensors, e. Turning on and turning off the power supply of system components.
I2C Info – I2C Bus, Interface and Protocol
Understanding the I2C Protocol