Monday 23 November 2015

I2C Protocol

                                                                     I2C Protocol


I²C (Inter-Integrated Circuit), pronounced I-squared-C, is a multi-master, multi-slave,single-endedserial computer bus invented by Philips Semiconductor (now NXP Semiconductors). It is typically used for attaching lower-speed peripheral ICs to processors and microcontrollers. Alternatively I²C is spelled I2C (pronounced I-two-C) or IIC(pronounced I-I-C).
Since October 10, 2006, no licensing fees are required to implement the I²C protocol. However, fees are still required to obtain I²C slave addresses allocated by NXP.[1]
Several competitors, such as Siemens AG (later Infineon Technologies AG, now Intel mobile communications), NEC, Texas Instruments, STMicroelectronics (formerly SGS-Thomson), Motorola (later Freescale), and Intersil, have introduced compatible I²C products to the market since the mid-1990s.
SMBus, defined by Intel in 1995, is a subset of I²C that defines the protocols more strictly. One purpose of SMBus is to promote robustness and interoperability. Accordingly, modern I²C systems incorporate policies and rules from SMBus, sometimes supporting both I²C and SMBus, requiring only minimal reconfiguration.

Message protocols

I²C defines basic types of messages, each of which begins with a START and ends with a STOP:
  • Single message where a master writes data to a slave;
  • Single message where a master reads data from a slave;
  • Combined messages, where a master issues at least two reads and/or writes to one or more slaves.
In a combined message, each read or write begins with a START and the slave address. After the first START in a combined message these are also called repeated START bits. Repeated START bits are not preceded by STOP bits, which is how slaves know the next transfer is part of the same message.
Any given slave will only respond to certain messages, as specified in its product documentation.
Pure I²C systems support arbitrary message structures. SMBus is restricted to nine of those structures, such as read word N and write word N, involving a single slave. PMBus extends SMBus with a Group protocol, allowing multiple such SMBus transactions to be sent in one combined message. The terminating STOP indicates when those grouped actions should take effect. For example, one PMBus operation might reconfigure three power supplies (using three different I2C slave addresses), and their new configurations would take effect at the same time: when they receive that STOP.
With only a few exceptions, neither I²C nor SMBus define message semantics, such as the meaning of data bytes in messages. Message semantics are otherwise product-specific. Those exceptions include messages addressed to the I²C general call address (0x00) or to the SMBus Alert Response Address; and messages involved in the SMBus Address Resolution Protocol (ARP) for dynamic address allocation and management.
In practice, most slaves adopt request/response control models, where one or more bytes following a write command are treated as a command or address. Those bytes determine how subsequent written bytes are treated and/or how the slave responds on subsequent reads. Most SMBus operations involve single byte commands.

CODE:
#include<htc.h>
#include"4 BITLCD.C"
#include"I2C.C"
#include"TIME_DATE.C"
void main()
{
TRISB=0X00;
TRISC=0X18; // SDI=SCL=1;
lcd_init();
i2c_init();
lcd_cmd(0X80,0);
lcd_str(" I2C BASED RTC ");
lcd_cmd(0X01,0);
lcd_cmd(0X80,0);
lcd_str("TIME:  :  :");
lcd_cmd(0XC0,0);
lcd_str("DATE:  :  :");
set_time(0X00,0X00); // SEC
set_time(0X01,0X01); // MIN
set_time(0X02,0X64); // HRS & AM/PM
set_time(0X03,0X04);
set_date(0X04,0X03); // DD
set_date(0X05,0X04); // MM
set_date(0X06,0X05); // YY
while(1)
{
get_time(0X00,0X8B);
get_time(0X01,0X88);
get_time(0X02,0X85);
get_date(0X04,0XC5);
get_date(0X05,0XC8);
get_date(0X06,0XCB);
}
}
CLICK HERE FOR MORE DETAILS AND PROTOCOLS

No comments:

Post a Comment