Line 1: Line 1:
{{Box|type=l_green_light|text=
+
{{Box|type=l_green_light|text=<br/>
It is uses '''I²C''' ('''Inter-Integrated Circuit''') protocol, referred to as ''I-squared-C'', ''I-two-C'', or ''IIC'') for communication with the micrcontroller.Let see first the basics of the communication protocol first.
+
=Introduction=
 +
The '''I²C''' ('''Inter-Integrated Circuit''') protocol, referred to as ''I-squared-C'', ''I-two-C'', or ''IIC'') is two wire serial communication protocol for connecting low speed peripherals to a micrcontroller or computer motherboard.
  
 
[[Image:I2C.png|thumb|350px|A sample schematic with one master and three slaves]]
 
[[Image:I2C.png|thumb|350px|A sample schematic with one master and three slaves]]
  
The '''I²C'''  require only two wires for communication. One is called the '''Serial Data (SDA)''' and the other is '''Serial Clock (SCL)''' as shown.
+
The '''I²C'''  simply require only two wires for communication. One is called the '''Serial Data (SDA)''' and the other is '''Serial Clock (SCL)''' as shown.
  
 
There are various modes and configurations in which it can be used. Let us start simply with a single master and a single slave.
 
There are various modes and configurations in which it can be used. Let us start simply with a single master and a single slave.
  
The Master generates the clock for serial communication
+
The Master generates the clock for serial communication('''SCL'''). A stream of data bits(B1 to BN) is transferred between the start and the stop bits.
  
 
=I2C Timings and Conditions.=
 
=I2C Timings and Conditions.=
Line 14: Line 15:
 
[[File:I2C data transfer.png|thumbnail|x100px|Fig: I2C data transfer]]
 
[[File:I2C data transfer.png|thumbnail|x100px|Fig: I2C data transfer]]
  
=Start Condition=
+
==Start Condition(S)==
 
As seen from the timing diagram, a data transfer  is initiated with the '''Start(S)''' condition. The start occurs when '''SCL''' is high and '''SDA''' goes from high to low.
 
As seen from the timing diagram, a data transfer  is initiated with the '''Start(S)''' condition. The start occurs when '''SCL''' is high and '''SDA''' goes from high to low.
  
  
 +
==Data bits transfer(B1...Bn)==
 +
A bit is transmitted at every high level of the clock (SCL) after the start condition. As shown in the image bits '''B1''' to '''Bn''' are transmitted at high level of every successive clock cycles.
  
 +
==Stop bit (P)==
 +
To stop the data transfer, the clock(SCL) is held high, while data(SDA) goes from low to high.
  
 +
=Interfacing Microcontroller to I2C devices=
 +
Usually, following procedure is used to communicate with the peripherals.
 +
*Master initializes the communication by sending the slave address on the bus.
 +
*Master reads or writes data or commands from and to the slaves depending on the interfaced devices.
 +
 +
We will see practical implementation of I2C on different peripherals and Micrcontrollers. The examples will be updated here.
 +
=Practical Examples=
 +
*[[Interfacing_RTC_DS1307_with_8051]]
  
 
}}
 
}}

Revision as of 15:29, 28 January 2014


Introduction

The I²C (Inter-Integrated Circuit) protocol, referred to as I-squared-C, I-two-C, or IIC) is two wire serial communication protocol for connecting low speed peripherals to a micrcontroller or computer motherboard.

A sample schematic with one master and three slaves

The I²C simply require only two wires for communication. One is called the Serial Data (SDA) and the other is Serial Clock (SCL) as shown.

There are various modes and configurations in which it can be used. Let us start simply with a single master and a single slave.

The Master generates the clock for serial communication(SCL). A stream of data bits(B1 to BN) is transferred between the start and the stop bits.

I2C Timings and Conditions.

Figure below shows the timing diagram for I²C.

Fig: I2C data transfer

Start Condition(S)

As seen from the timing diagram, a data transfer is initiated with the Start(S) condition. The start occurs when SCL is high and SDA goes from high to low.


Data bits transfer(B1...Bn)

A bit is transmitted at every high level of the clock (SCL) after the start condition. As shown in the image bits B1 to Bn are transmitted at high level of every successive clock cycles.

Stop bit (P)

To stop the data transfer, the clock(SCL) is held high, while data(SDA) goes from low to high.

Interfacing Microcontroller to I2C devices

Usually, following procedure is used to communicate with the peripherals.

  • Master initializes the communication by sending the slave address on the bus.
  • Master reads or writes data or commands from and to the slaves depending on the interfaced devices.

We will see practical implementation of I2C on different peripherals and Micrcontrollers. The examples will be updated here.

Practical Examples