I2C How It Works PDF Print E-mail
Written by Administrator   
Sunday, 17 May 2009 00:37

 I2C

 Simple I2C Implementation for Microcontrollers

There is a huge variety of microcontrollers out there. Some have lots of I/O lines, some have only a few. Very frequently you would like to have more I/O lines than your favorite MCU has. There are different approaches towards this, depending on the speed requirements and software effort. This article will concentrate on a solution called I2C developed by Philips . This is an extremely simple protocol for communicating with other chips using just two signal wires. This is interesting to embedded systems engineers, because it is relatively simple to implement I2C in software.

 

How It Works ( Simplest implementation)

I2C is a serial bus.  There are two lines, a clock line and a data line. Both these lines are bi-directional open-collector signals. This means that any device on the bus can pull either line low; There are pullup resistors to make the line go high if no device is bringing the line low. In the simple implementation, there is one device which is the Master. The CPU will control the clock line (SCL), although Slave devices can hold the clock low in certain cases. The SCL line typically counts out the bits of data appearing on the data (SDA) line. By this we mean that every time SCL has a rising edge, the SDA line can be sampled.

The following sections cover the details of how I2C transactions work. I2c transactions start with the master synchronizing with the receivers by issueing a START condition on the bus. Then the desired Slave address is put onto the bus by the Master. Finally, if the Slave acknowledges the address, the data is put out onto the bus and the transaction ends.

Differences between I2C and RS232

Despite the fact that both I2C and RS232 are serial interfaces, I2C is quite different from RS232 in two ways. One difference is that in RS232 each wire is a one-way signal.  The receiver never drives the recv data wire, whereas in I2C, both devices at times control the one data line. Another difference with RS232 is that you can hang multiple devices on the same wires. Hence, I2C is a serial BUS. The third difference is that RS232 has no clock line. Communicate depends on the data changing state at specified time intervals. The reciever will know when to check the data line based on the amount of time which has passed since the 'Start' event. I2C has a clock line, and the data is sampled on the low-to-high transition of the clock signal.

 I2C Whole Transaction

 

Anatomy of a I2C Transaction

The above figure shows a write of a single byte via I2C. The major features of the transaction are the START event, the sending of the address by the master, then the sending of the 8 bits of data. Finally, the transaction is finished with the STOP event. Each part of the transaction is disected below.

START and STOP Synchronizing Events

I2C Start and Stop

 In order for all the devices to remain synchronized, there needs to be a way to signal the start of a transaction. The master can indicate this with a START condition. This is defined as the master bringing the SDA line making a high-to-low transition when SCL is high. Under normal data transfer, the slave is not allowed to change the state of the SDA line. Thus, a slave cannot initiate a transaction. 

<- Prev     Next ->

 

 

Last Updated on Sunday, 17 May 2009 13:42
 

Sponsored Links

Bold Inventions, Powered by Joomla!; Joomla templates by SG web hosting