I2C 协议标准完全版,很详细
I2C总线协议
I2C总线协议 - subkiller的专栏 - 博客频道 - CSDN1.I2C协议2条双向串行线,一条数据线SDA,一条时钟线SCL。
SDA传输数据是大端传输,每次传输8bit,即一字节。
支持多主控(multimastering),任何时间点只能有一个主控。
总线上每个设备都有自己的一个addr,共7个bit,广播地址全0.系统中可能有多个同种芯片,为此addr分为固定部分和可编程部份,细节视芯片而定,看datasheet。
1.1 I2C位传输数据传输:SCL为高电平时,SDA线若保持稳定,那么SDA上是在传输数据bit;若SDA发生跳变,则用来表示一个会话的开始或结束(后面讲)数据改变:SCL为低电平时,SDA线才能改变传输的bit1.2 I2C开始和结束信号开始信号:SCL为高电平时,SDA由高电平向低电平跳变,开始传送数据。
结束信号:SCL为高电平时,SDA由低电平向高电平跳变,结束传送数据。
1.3 I2C应答信号Master每发送完8bit数据后等待Slave的ACK。
即在第9个clock,若从IC发ACK,SDA会被拉低。
若没有ACK,SDA会被置高,这会引起Master发生RESTART或STOP流程,如下所示:1.4 I2C写流程写寄存器的标准流程为:1. Master发起START2. Master发送I2C addr(7bit)和w操作0(1bit),等待ACK3. Slave发送ACK4. Master发送reg addr(8bit),等待ACK5. Slave发送ACK6. Master发送data(8bit),即要写入寄存器中的数据,等待ACK7. Slave发送ACK8. 第6步和第7步可以重复多次,即顺序写多个寄存器9. Master发起STOP写一个寄存器写多个寄存器1.5 I2C读流程读寄存器的标准流程为:1. Master发送I2C addr(7bit)和w操作1(1bit),等待ACK2. Slave发送ACK3. Master发送reg addr(8bit),等待ACK4. Slave发送ACK5. Master发起START6. Master发送I2C addr(7bit)和r操作1(1bit),等待ACK7. Slave发送ACK8. Slave发送data(8bit),即寄存器里的值9. Master发送ACK10. 第8步和第9步可以重复多次,即顺序读多个寄存器读一个寄存器读多个寄存器2. PowerPC的I2C实现Mpc8560的CCSR中控制I2C的寄存器共有6个。
II2C总线协议
II2C总线协议】
2009年03月04日星期三 11:22
总线传输协议】
【I2C
常用的串行扩展总线有I2C、单总线、Microwir/PLUS等!
I2C总线通过上拉电阻接正电源,通常接10K的电阻.当总线空闲时、两根线均为高电平,并且SDA、SCL是线与线!
#传输协议
一、数据位有效性规定
根据时序图: SCL为高电平期间、SDA的数据必须保持稳定(也就是说数据必须在SCL为高电平时候、才能传送)、当SCL为低电平期间、SDA的数据位可改变(也就是说这个时候才可以改变数据位).
也就是说、SDA是根据SCL(时钟脉冲)的电平来决定的,当SCL在高电平时(时钟脉冲)、SDA 随即同步发送或接收.
二、起始和终止信号
起始信号是SCL线为高电平期间、SDA线由高电平向低电平跳变!!!
终止信号是SCL为高电平时、SDA线由低电平向高电平的跳变!!!!
三、数据传输格式:
也就是在起始信号和终止信号的中间阶段!!
字节传送与应答
8位数据、最先传送的是最高位,并且在最后一位是应答位,即一帧为9位!
起始信号后的8位数据:
前7位为地址:后1位为方向位,0表示发送、1表示接收!
终止信号始终都是主机发送的,但是在发送一次数据后也可以不终止、而继续寻址新的从机!。
i2c协议参数
i2c协议参数I2C协议参数I2C总线是一种串行通信协议,由飞利浦公司(现在的恩智浦半导体公司)开发。
它被广泛应用于各种电子设备中,例如传感器、存储器、数字转换器等。
本文将详细介绍I2C协议的各种参数。
一、物理层参数1. 电压:I2C总线标准电平为5V,但也有3.3V和1.8V版本。
不同版本的电压对应着不同的速率和距离限制。
2. 速率:I2C总线有多种速率可供选择,最高达到400kHz。
速率越高,数据传输越快,但同时也会增加误差和干扰。
3. 距离限制:I2C总线的距离限制取决于电压和速率。
在5V电平下,最大距离约为10米;在3.3V电平下,最大距离约为5米。
二、数据帧格式1. 起始位:一个高电平到低电平的转换表示开始一个传输周期。
2. 地址位:7位或10位地址码表示要访问的设备地址。
3. 读写位:一个读写位指示主机是要读取还是写入数据。
4. 应答位:设备在接收到地址位后需要发送一个应答位,表示它已经准备好接收数据。
5. 数据位:8位数据表示要传输的数据。
6. 停止位:一个低电平到高电平的转换表示传输周期结束。
三、时序参数1. SCL时钟频率:SCL时钟频率是I2C总线的主要参数之一,它决定了数据传输速率。
标准模式下,SCL频率为100kHz;快速模式下,SCL频率为400kHz;高速模式下,SCL频率可达到3.4MHz。
2. 数据保持时间(tHD;DAT):数据保持时间是指从SCL时钟的最后一个上升沿到SDA线上数据变化的最小时间间隔。
标准模式下,tHD;DAT为0.1μs;快速模式下,tHD;DAT为0.9μs;高速模式下,tHD;DAT为0.45μs。
3. 数据建立时间(tSU;DAT):数据建立时间是指从SCL时钟的第一个上升沿到SDA线上数据变化的最小时间间隔。
标准模式下,tSU;DAT为0.1μs;快速模式下,tSU;DAT为0.6μs;高速模式下,tSU;DAT为0.25μs。
4. 停止条件保持时间(tSP):停止条件保持时间是指从SCL时钟的最后一个下降沿到SDA线上数据变化的最小时间间隔。
i2c总线协议中文版
i2c总线协议中文版i2c总线协议(中文版)双方基本信息:甲方:________(本协议中简称“甲方”)乙方:________(本协议中简称“乙方”)甲乙双方在平等自愿、公平诚信的基础上,达成以下协议:第一条:各方身份及权利义务1. 甲方:具有独立法人资格的企业/机构/个人,有权利利用i2c总线协议的技术进行数据传输。
2. 乙方:具有独立法人资格的企业/机构/个人,需经甲方授权并遵守本协议规定,方可使用i2c总线协议进行数据传输。
3. 甲方的权利和义务:(1)甲方有权利根据自身业务需求授权乙方使用i2c总线协议。
(2)甲方有义务提供符合要求的i2c总线协议技术使用授权,并提供技术支持、服务维护等后续工作。
(3)甲方需遵守国家相关法律法规,确保i2c总线协议技术的合法性和安全性。
(4)甲方需确保i2c总线协议技术的稳定性,同时积极处理技术问题,保障乙方的正常使用。
4. 乙方的权利和义务:(1)乙方有权利使用甲方授权的i2c总线协议技术进行数据传输。
(2)乙方有义务确保使用i2c总线协议技术时严格遵守本协议及国家、地方的相关法律法规。
(3)乙方须按照甲方要求缴纳使用费用或提供合理的使用补偿。
(4)乙方有义务根据i2c总线协议技术规范进行合法使用、正确操作,同时承担因非法操作而造成的损失和所有法律责任。
第二条:履行方式及期限1. 甲乙双方应在协议签署后尽快履行自身的权利和义务,确保i2c总线协议技术的顺利实施。
2. 甲方应根据乙方需求及使用情况,提供技术支持和维护服务,保障i2c总线协议技术的功能和稳定性。
3. 乙方应在使用i2c总线协议技术前,审慎阅读本协议,了解相关规定和责任,并按照要求进行支付或补偿等合法操作。
第三条:违约责任1. 甲乙双方如有违反合同约定的行为,将承担相应的违约责任。
2. 若甲方未按照协议规定向乙方提供技术支持和维护服务,或因技术问题造成乙方无法正常使用,甲方应承担相应的赔偿责任。
I2C通信协议20070 924
I2C通信协议20070 924I2C通讯协议一、通讯接口二、通讯格式 SCL:时钟信号线1、通讯帧格式SDA:数据信号线控制字节/地址测试项目参数1 参数2 参数n2byte 1byte 1byte 1byte 1byte BUSY:片选线2、字节传输格式,I2C,3、通讯建立过程A、主机发起通讯建立过程:首先,主机向从机发起通讯请求,即将相应的从机片选线拉到低电平,并保持一段时间,20ms,;而后,主机释放片选线,等待从机的响应,即:检测从机是否保持片选线为低电平,如果从机保持片选线为低电平状态,则表明主机不从机握手成功,主机主动发送“起始位,写控制字节,从机地址―――停止位”, 在逐个字节传输过程中,主机每向从机发送一个字节,则在第9个时钟等待从机的应答位,如果位没有检测到从机应答,则重新开始发送“起始位,写控制字节,从机地址―――停止位”,如此重复发送,如果重复发送10次没有成功,则放弃当前通讯操作。
B、从机发起通讯建立过程:首先,从机向主机发起通讯请求,即将从机自身的片选线拉到低电平,并保持一段时间,10ms,;而后,从机释放片选线,等待主机的响应,即:检测主机是否保持片选线为低电平,如果主机保持片选线为低电平状态,则表明从机不主机握手成功,主机主动发送“起始位,写控制字节,从机地址―起始位,读控制字――停止位”, 在逐个字节传输过程中,主机每向从机发送一个字节,则在第9个时钟等待从机的应答位,如果位没有检测到从机应答,则重新开始发送“起始位,写控制字节,从机地址―――停止位”,如此重复发送,如果重复发送10次没有成功,则放弃当前通讯操作。
三、通讯过程主要参数1、状态线保持时间:20ms,40ms2、通讯速率:<100kbps四、I2C主机、从机地址定义序号 I2C通讯模块主机/从机地址1 LCD显示模块主机:6E2 按键模块从机:7A3 通道1模块从机:7B4 通道2模块从机:7C5 通道3模块从机:7D五、各模块控制命令定义1、PWM1模块通讯命令高4位低4位测试项目测试命令 D7 D6 D5 D4 D3 D2 D1 D0停止 0X00 X X X X 0 0 0 0 OV 0X01 X X X X 0 0 0 1 LV 0X02 X X X X 0 0 1 0 OCP 0X03 X X X X 0 0 1 1 IR 0X04 X X X X 0 1 0 0 IDR 0X05 X X X X 0 1 0 1THR 0X06 X X X X 0 1 1 0过过CAP 0X07 工作模式 0 1 1 1 放充送标志位0X08 X X X X 1 0 0 0 寄存器注:X:为任意值测试CAP时,D7,过放测试开关标志位,1:开启,0:关闭测试CAP时,D6,过充测试开关标志位,1:开启,0:关闭测试CAP时,D5|D4,工作模式选择位,00:C<->D01:C->D10:C11:D**********************OV测试命令,0X01,**************************** 下发命令:从地址测试项目F6/F7-0X00 0X01上报结果:(0-1000) 单位:10mV从地址测试项目测试结果1 测试结果2F6/F7-0X00 0X01 OV_HI,10mV, OV_LO,10mV,**********************LV测试命令,0X01,**************************** 下发命令:从地址测试项目参数1F6/F7-0X00 0X02 带载电流,100mA,上报结果:(0-1000) 单位:10mV从地址测试项目测试结果1 测试结果2F6/F7-0X00 0X02 LV_HI,10mV, LV_LO,10mV,**********************OCP测试命令,0X03,****************************下发命令:从地址测试项目参数1 参数2F6/F7-0X00 0X03 保护电流,100mA,不保护电流,100mA,上报结果:(0或1)从地址测试项目测试结果F6/F7-0X00 0X03 PASS(0X01)/FAIL(0X00)**********************IR测试命令,0X04,**************************** 下发命令:从地址测试项目F6/F7-0X00 0X04上报结果:(0-500) 单位:2mR从地址测试项目测试结果1 测试结果2F6/F7-0X00 0X04 IR_HI,2mR, IR_LO (2 mR)**********************IDR测试命令,0X05,****************************下发命令:从地址测试项目F6/F7-0X00 0X05上报结果:(1-5000) 单位:0.1K从地址测试项目测试结果1 测试结果2F6/F7-0X00 0X05 IDR_HI,0.1K, IDR_LOW,0.1K,**********************THR测试命令,0X06,****************************下发命令:从地址测试项目F6/F7-0X00 0X06上报结果:(1-5000) 单位:0.1K从地址测试项目测试结果1 测试结果2F6/F7-0X00 0X06 THR_HI,0.1K, THR_LOW,0.1K,**********************OCP测试命令,0X06,****************************下发命令:从地址测试项目参数1 参数2F6/F7-0X01 0X06 保护电流,100mA,不保护电流,100mA,上报结果:(0或1)从地址测试项目测试结果F6/F7-0X01 0X06 PASS(0X01)/FAIL(0X00)**********************CAP测试命令,0X07,****************************下发命令:从地址测试项目参数1 参数2F6/F7-0X01 0X?7 充电电流,100 mA,放电电流,100 mA,参数3 参数4 参数5 参数6充饱电压放电终止过充保护,100mV,过放保护,100mV,,100mV,,100mV,上报结果:(1-8000) 单位:1mAh从地址测试项目测试结果1 测试结果2F6/F7-0X00 0X?7 CAP_HI,1mAh, CAP_LOW,1mAh,其中“0X?7”表示的含义如下:高4位低4位测试项目测试命令 D7 D6 D5 D4 D3 D2 D1 D0过过CAP 0X07 工作模式 0 1 1 1 放充注:测试CAP时,D7,过放测试测试结果标志位,1:PASS,0:FAIL测试CAP时,D6,过充测试测试结果标志位,1:PASS,0:FAIL测试CAP时,D5|D4,当前测试工作模式选择位,00:C<->D01:C->D10:C11:D***************************送标志位寄存器************************* 下发命令从地址测试项目F6/F7-0X00 0X08上报结果从地址测试项目测试结果F6/F7-0X00 0X08 标志寄存器,MARK,送标志位寄存器:主机,用户设定好参数后,在下发要求测试前先要求从机将电池的状态发送给主机,主机以便判断客户所设定的参数是否符合电池节数的要求,如不符合应提示设定参数不对的提示,要求从机送判断电池状态的标志位MARK:MARK,0 ;电池是否接入,如接入则标志位为1MARK,1 ;电池输出短路是否为短路,如短路则标志位为1 MARK,2 ;电池电压是否过高,8.9V,,如过高则标志位为1 MARK,3 ;电池是1节还是2节,如是2节为1,如是1节为0主机接收电池节数并限定客户设置值不应超出如下的值:充饱电压:1节?4.25V,2节?8.5V 1.放电终止电压:1节?2.7V,2节?5.4V 2.过充保护电压:1节?4.45V,2节?8.9 3.过放保护电压:1节?2V,2节?4V 4.2、PWM2模块通讯命令高4位低4位测试项目测试命令 D7 D6 D5 D4 D3 D2 D1 D0 停止 0X00 X X X X 0 0 0 0保留 0X01 X X X X 0 0 0 1保留 0X02 X X X X 0 0 1 0保留 0X03 X X X X 0 0 1 1保留 0X04 X X X X 0 1 0 0保留 0X05 X X X X 0 1 0 1保留 0X06 X X X X 0 1 1 0过过CAP 0X07 工作模式 0 1 1 1 放充送标志位0X08 X X X X 1 0 0 0 寄存器注:X:为任意值测试CAP时,D7,过放测试开关标志位,1:开启,0:关闭测试CAP时,D6,过充测试开关标志位,1:开启,0:关闭测试CAP时,D5|D4,工作模式选择位,00:C<->D01:C->D10:C11:D**********************CAP测试命令,0X07,****************************下发命令:从地址测试项目参数1 参数2F6/F7-0X02 0X?7 充电电流,100 mA,放电电流,100 mA,参数3 参数4 参数5 参数6充饱电压放电终止过充保护,100mV,过放保护,100mV,,100mV,,100mV,上报结果:(1-8000) 单位:1mAh从地址测试项目测试结果1 测试结果2F6/F7-0X02 0X?7 CAP_HI,1mAh, CAP_LOW,1mAh,其中“0X?7”表示的含义如下:高4位低4位测试项目测试命令 D7 D6 D5 D4 D3 D2 D1 D0过过CAP 0X07 工作模式 0 1 1 1 放充注:测试CAP时,D7,过放测试测试结果标志位,1:PASS,0:FAIL测试CAP时,D6,过充测试测试结果标志位,1:PASS,0:FAIL测试CAP时,D5|D4,当前测试工作模式选择位,00:C<->D01:C->D10:C11:D***************************送标志位寄存器************************* 下发命令从地址测试项目F8/F9-0X00 0X08上报结果从地址测试项目测试结果F8/F9-0X00 0X08 标志寄存器,MARK,送标志位寄存器:主机,用户设定好参数后,在下发要求测试前先要求从机将电池的状态发送给主机,主机以便判断客户所设定的参数是否符合电池节数的要求,如不符合应提示设定参数不对的提示,要求从机送判断电池状态的标志位MARK:MARK,0 ;电池是否接入,如接入则标志位为1MARK,1 ;电池输出短路是否为短路,如短路则标志位为1MARK,2 ;电池电压是否过高,8.9V,,如过高则标志位为1MARK,3 ;电池是1节还是2节,如是2节为1,如是1节为0充饱电压:1节?4.25V,2节?8.5V 主机接收电池节数并限定客户设置值不应超出如下的值: 放电终止电压:1节?2.7V,2节?5.4V 2.1. 过充保护电压:1节?4.45V,2节?8.9 3.过放保护电压:1节?2V,2节?4V 4.3、PWM3模块通讯命令高4位低4位测试项目测试命令 D7 D6 D5 D4 D3 D2 D1 D0停止 0X00 X X X X 0 0 0 0保留 0X01 X X X X 0 0 0 1保留 0X02 X X X X 0 0 1 0保留 0X03 X X X X 0 0 1 1保留 0X04 X X X X 0 1 0 0保留 0X05 X X X X 0 1 0 1保留 0X06 X X X X 0 1 1 0过过CAP 0X07 工作模式 0 1 1 1 放充送标志位0X08 X X X X 1 0 0 0 寄存器注:X:为任意值测试CAP时,D7,过放测试开关标志位,1:开启,0:关闭测试CAP时,D6,过充测试开关标志位,1:开启,0:关闭测试CAP时,D5|D4,工作模式选择位,00:C<->D01:C->D10:C11:D**********************CAP测试命令,0X07,****************************下发命令:从地址测试项目参数1 参数2F6/F7-0X03 0X?7 充电电流,100 mA,放电电流,100 mA,参数3 参数4 参数5 参数6充饱电压放电终止过充保护,100mV,过放保护,100mV,,100mV,,100mV,上报结果:(1-8000) 单位:1mAh从地址测试项目测试结果1 测试结果2F6/F7-0X03 0X?7 CAP_HI,1mAh, CAP_LOW,1mAh,其中“0X?7”表示的含义如下:高4位低4位测试项目测试命令 D7 D6 D5 D4 D3 D2 D1 D0过过CAP 0X07 工作模式 0 1 1 1 放充注:测试CAP时,D7,过放测试测试结果标志位,1:PASS,0:FAIL测试CAP时,D6,过充测试测试结果标志位,1:PASS,0:FAIL测试CAP时,D5|D4,当前测试工作模式选择位,00:C<->D01:C->D10:C11:D***************************送标志位寄存器************************* 下发命令从地址测试项目FA/FB-0X00 0X08上报结果从地址测试项目测试结果FA/FB-0X00 0X08 标志寄存器,MARK,送标志位寄存器:主机,用户设定好参数后,在下发要求测试前先要求从机将电池的状态发送给主机,主机以便判断客户所设定的参数是否符合电池节数的要求,如不符合应提示设定参数不对的提示,要求从机送判断电池状态的标志位MARK:MARK,0 ;电池是否接入,如接入则标志位为1MARK,1 ;电池输出短路是否为短路,如短路则标志位为1MARK,2 ;电池电压是否过高,8.9V,,如过高则标志位为1MARK,3 ;电池是1节还是2节,如是2节为1,如是1节为0主机接收电池节数并限定客户设置值不应超出如下的值: 充饱电压:1节?4.25V,2节?8.5V放电终止电压:1节?2.7V,2节?5.4V 1.2.过充保护电压:1节?4.45V,2节?8.9 3.过放保护电压:1节?2V,2节?4V 4.4、LEDC模块通讯命令**************************读取键值************************ 从地址读取键值F4/F5-0X00 0,F**************************更新LED************************从地址 CH1-LED显示值 CH2-LED显示值 CH3-LED显示值F4/F5-0X01 PA-PB PA-PB PA-PB。
I2c总线协议
1.I2C协议2条双向串行线,一条数据线SDA,一条时钟线SCL。
SDA传输数据是大端传输,每次传输8bit,即一字节。
支持多主控(multimastering),任何时间点只能有一个主控。
总线上每个设备都有自己的一个addr,共7个bit,广播地址全0.系统中可能有多个同种芯片,为此addr分为固定部分和可编程部份,细节视芯片而定,看datasheet。
1.1 I2C位传输数据传输:SCL为高电平时,SDA线若保持稳定,那么SDA上是在传输数据bit;若SDA发生跳变,则用来表示一个会话的开始或结束(后面讲)数据改变:SCL为低电平时,SDA线才能改变传输的bit1.2 I2C开始和结束信号开始信号:SCL为高电平时,SDA由高电平向低电平跳变,开始传送数据。
结束信号:SCL为高电平时,SDA由低电平向高电平跳变,结束传送数据。
1.3 I2C应答信号Master每发送完8bit数据后等待Slave的ACK。
即在第9个clock,若从IC发ACK,SDA会被拉低。
若没有ACK,SDA会被置高,这会引起Master发生RESTART或STOP流程,如下所示:1.4 I2C写流程写寄存器的标准流程为:1. Master发起START2. Master发送I2C addr(7bit)和w操作0(1bit),等待ACK3. Slave发送ACK4. Master发送reg addr(8bit),等待ACK5. Slave发送ACK6. Master发送data(8bit),即要写入寄存器中的数据,等待ACK7. Slave发送ACK8. 第6步和第7步可以重复多次,即顺序写多个寄存器9. Master发起STOP写一个寄存器写多个寄存器1.5 I2C读流程读寄存器的标准流程为:1. Master发送I2C addr(7bit)和w操作1(1bit),等待ACK2. Slave发送ACK3. Master发送reg addr(8bit),等待ACK4. Slave发送ACK5. Master发起START6. Master发送I2C addr(7bit)和r操作1(1bit),等待ACK7. Slave发送ACK8. Slave发送data(8bit),即寄存器里的值9. Master发送ACK10. 第8步和第9步可以重复多次,即顺序读多个寄存器读一个寄存器读多个寄存器2. PowerPC的I2C实现Mpc8560的CCSR中控制I2C的寄存器共有6个。
I2C通讯协议
I2C通讯协议协议名称:I2C通讯协议1. 引言I2C(Inter-Integrated Circuit)通讯协议是一种串行通信协议,用于在集成电路之间进行数据传输。
本协议旨在规范I2C通讯的硬件连接、信号传输、地址分配、数据格式和通讯协议等方面的要求,以确保不同设备之间的互操作性和数据传输的可靠性。
2. 范围本协议适用于使用I2C通讯协议进行数据交换的所有设备和系统。
3. 术语和定义3.1 主设备(Master Device): 发起I2C通讯的设备。
3.2 从设备(Slave Device): 响应I2C通讯的设备。
3.3 传输速率(Transfer Rate): 数据在I2C总线上的传输速度,通常以kHz为单位。
3.4 总线(Bus): 用于连接主设备和从设备的物理通道。
3.5 起始条件(Start Condition): 主设备发起通讯的信号。
3.6 停止条件(Stop Condition): 主设备结束通讯的信号。
3.7 位(Bit): I2C通讯中的最小数据单位。
3.8 字节(Byte): 由8个位组成的数据单元。
4. 硬件连接4.1 I2C总线由两根信号线组成:时钟线(SCL)和数据线(SDA)。
4.2 主设备通过SCL线提供时钟信号,从设备根据该信号进行数据传输。
4.3 主设备和从设备共享同一根SDA线进行数据传输。
4.4 每个设备在总线上都有一个唯一的7位地址,用于标识设备。
5. 信号传输5.1 传输速率由主设备控制,通常可选的速率为100 kHz、400 kHz和1 MHz。
5.2 通信过程中,主设备发起起始条件,从设备在检测到起始条件后进入接收状态。
5.3 数据传输以字节为单位进行,每个字节由8个位组成。
5.4 数据传输时,每个位在SCL的上升沿或下降沿进行传输。
5.5 主设备发送数据时,从设备在SCL的下降沿采样数据。
5.6 从设备发送数据时,主设备在SCL的上升沿采样数据。
I2C总线协议介绍(易懂)
I2C总线协议介绍(易懂)目录CONTENTS•I2C总线协议产生背景•I2C总线协议内容介绍•I2C总线协议总结一、I2C总线协议产生背景1电视机内IC 之间相互连接,IC 芯片体积增大功耗增大 成本增加 IC 芯片应用不便飞利浦公司为了硬件电路最简化,效益最大化,给芯片设计制造者和芯片应用者带来极大益处。
2 I2C 总线Logo3飞利浦公司将这种集成电路互连通信电路命名为Inter-Integrated Circuit,简称为Inter-IC,或I2C(数字“2”为上标)。
因为I2C中的两根导线(SDA和SCL)构成了两根Bus,实现了Bus的功能;由于I2C电路能实现Bus的功能,故把I2C 电路称为 I2C-Bus,中文叫I2C总线(I2C总线是一个两线总线)。
4在正式的书面场合,全称写作Inter-Integrated Circuit,简写Inter-IC(IIC)或者I2C(数字“2”书写为上标,,英文读作“I squared C”,中文读作“I平方C”)5I2C总线术语及定义,如表(1)所示:表(1) I2C总线术语及定义6最初,I2C总线的运行速度被限制在100 Kbit /s。
随着技术的发展,对该规范进行了多次补充与更新,现在有五种运行速度模式,如表(2)所示:表(2)I2C总线传输速度模式二、I2C总线协议内容1I2C Bus 只要求两条双向线路:串行数据线(serial data SDA)与串行时钟线SCL(serialclock SCL),两条线都是双向传输的。
每个连接到总线的器件都有唯一的地址,主控制器发出的控制信息分为地址码和控制量两部分,地址码用来选择需要控制的I2C设备,控制量包含类别(写与读)2I2C总线是一种多控制器总线,总线上可以连接多个控制器和多个从机,这些控制器都可以发起对总线的控制,通过仲裁机制,同一个时刻,只能有一个控制器获得控制权,其他控制器轮流获取总线的控制权。
I2c总线协议
1.I2C协议2条双向串行线,一条数据线SDA,一条时钟线SCL。
SDA传输数据是大端传输,每次传输8bit,即一字节。
支持多主控(multimastering),任何时间点只能有一个主控。
总线上每个设备都有自己的一个addr,共7个bit,广播地址全0.系统中可能有多个同种芯片,为此addr分为固定部分和可编程部份,细节视芯片而定,看datasheet。
1.1 I2C位传输数据传输:SCL为高电平时,SDA线若保持稳定,那么SDA上是在传输数据bit;若SDA发生跳变,则用来表示一个会话的开始或结束(后面讲)数据改变:SCL为低电平时,SDA线才能改变传输的bit1.2 I2C开始和结束信号开始信号:SCL为高电平时,SDA由高电平向低电平跳变,开始传送数据。
结束信号:SCL为高电平时,SDA由低电平向高电平跳变,结束传送数据。
1.3 I2C应答信号Master每发送完8bit数据后等待Slave的ACK。
即在第9个clock,若从IC发ACK,SDA会被拉低。
若没有ACK,SDA会被置高,这会引起Master发生RESTART或STOP流程,如下所示:1.4 I2C写流程写寄存器的标准流程为:1. Master发起START2. Master发送I2C addr(7bit)和w操作0(1bit),等待ACK3. Slave发送ACK4. Master发送reg addr(8bit),等待ACK5. Slave发送ACK6. Master发送data(8bit),即要写入寄存器中的数据,等待ACK7. Slave发送ACK8.第6步和第7步可以重复多次,即顺序写多个寄存器9. Master发起STOP写一个寄存器写多个寄存器1.5 I2C读流程读寄存器的标准流程为:1. Master发送I2C addr(7bit)和w操作1(1bit),等待ACK2. Slave发送ACK3. Master发送reg addr(8bit),等待ACK4. Slave发送ACK5. Master发起START6. Master发送I2C addr(7bit)和r操作1(1bit),等待ACK7. Slave发送ACK8. Slave发送data(8bit),即寄存器里的值9. Master发送ACK10.第8步和第9步可以重复多次,即顺序读多个寄存器读一个寄存器读多个寄存器2. PowerPC的I2C实现Mpc8560的CCSR中控制I2C的寄存器共有6个。
I2C通信协议详细讲解
I2C通信协议详细讲解I2C(Inter-Integrated Circuit)是一种串行通信协议,由Philips公司于1980年代初开发,旨在实现多个集成电路之间的简单、高效通信。
I2C协议适用于芯片之间的通信,如存储器、A/D转换器、传感器等。
它具有两根线,一根是时钟线(SCL),用于同步数据传输,另一根是数据线(SDA),用于传输数据。
以下是I2C协议的详细讲解。
1.总线拓扑I2C总线是基于主从架构,其中一个设备充当主设备(Master),其他设备作为从设备(Slave)。
总线上最多可以连接112个从设备,每个从设备通过唯一的地址进行识别。
2.通信格式I2C通信由一系列的起始位、地址位、数据位和停止位组成。
在通信开始之前,主设备负责发出起始位(Start Bit),表示通信开始。
接着主设备发送从设备的7位地址(最低位用于指示读写操作),从设备在总线上进行匹配。
如果从设备地址匹配成功,主设备发送数据或命令给从设备;若从设备地址匹配失败,主设备发送停止位(Stop Bit)结束通信。
3.传输速率I2C协议定义了几种标准的传输速率,如标准模式(Standard Mode)的速率为100 kHz,快速模式(Fast Mode)的速率为400 kHz,高速模式(High-Speed Mode)的速率为3.4 MHz。
除此之外,还有更高速的模式如超高速模式(Ultra Fast Mode)和超快速模式(Ultra Fast Mode),速率分别为5 MHz和25 MHz。
4.时钟同步5.主设备模式主设备可以发送起始位、地址位、数据位和停止位。
它与从设备之间可以进行单向或双向通信。
主设备可以向从设备发送读请求或写请求,并且可以按照需要在传输过程中发出重启位(Repeated Start Bit)来处理多个数据传输操作。
6.从设备模式从设备通过地址识别来接受或发送数据。
从设备可以处于可寻址模式(Addressable Mode)或普通模式(General Call Mode)。
详细阐述i2c通信协议
详细阐述i2c通信协议合同标题:“i2c通信协议详细阐述”一、合同双方基本信息甲方(公司名):_____,注册地址:_____,统一社会信用代码:_____,联系方式:_____。
乙方(公司名):_____,注册地址:_____,统一社会信用代码:_____,联系方式:_____。
二、各方身份、权利、义务、履行方式、期限、违约责任1. 甲方身份:i2c协议使用者,拥有i2c协议的使用权;权利:享有使用i2c协议进行通信交互的权利;义务:确保i2c协议不被恶意使用,不泄露i2c协议内容;履行方式:遵循i2c通信协议进行通信交互;期限:协议有效期从甲方使用i2c协议之日起至解约之日止;违约责任:(1)未经乙方书面同意,擅自修改、更改i2c通信协议的,乙方有权终止甲方的使用权;(2)因甲方自身原因导致通信不稳定或无法连接,甲方应自行承担相应的责任。
2. 乙方身份:i2c协议提供方,拥有i2c协议的版权和使用权;权利:享有i2c协议的版权和使用权,有权监督和管理甲方对i2c协议的使用;义务:向甲方提供可靠、稳定的i2c通信协议,确保i2c协议符合测试标准和相关规范,维护版本更新和修复错误;履行方式:提供稳定的i2c通信协议,随时提供技术支持与协助;期限:协议有效期从甲方使用i2c协议之日起至解约之日止;违约责任:(1)甲方发现i2c 协议存在质量问题或缺陷,应及时通知乙方协商解决,如果乙方不能在合理时间内解决,则甲方可以终止使用i2c协议,同时乙方应承担相应责任。
(2)乙方违反法律或协议的规定,从而导致甲方的损失,应承担相应的赔偿责任。
三、遵守中国的相关法律法规本协议各项条款应符合中华人民共和国相关法律法规,如果发现不合法的情况,应及时更正,确保遵守法律。
四、明确各方的权力和义务本协议明确规定了甲、乙双方在i2c通信协议使用过程中的权利和义务,明确了乙方对i2c协议的版权和使用权,甲方对i2c协议的使用权,以及各方在协议履行过程中的责任与义务等。
I2C通讯协议
I2C通讯协议协议名称:I2C通讯协议1. 引言I2C通讯协议是一种用于集成电路(Integrated Circuit,简称IC)之间进行通信的串行通信协议。
本协议旨在规范I2C通信的格式、电气特性、数据传输速率以及设备地址分配等方面的要求,以确保不同厂商生产的IC能够在I2C总线上进行可靠的通信。
2. 范围本协议适合于使用I2C通信协议的所有设备和系统,包括但不限于集成电路、传感器、存储器等。
3. 术语和定义以下术语和定义适合于本协议:- 主设备(Master Device):发起I2C通信的设备。
- 从设备(Slave Device):响应I2C通信的设备。
- 总线(Bus):用于连接主设备和从设备的物理通信路线。
- 传输速率(Transfer Rate):主设备和从设备之间传输数据的速度。
- 设备地址(Device Address):用于识别从设备的惟一地址。
4. 电气特性4.1 电压I2C总线上的电压应符合以下要求:- 逻辑高电平(V_H):2.1V至5.5V。
- 逻辑低电平(V_L):0V至0.7V。
- 上拉电阻(R_PU):主设备和从设备上的上拉电阻应保证逻辑高电平的稳定。
4.2 时钟速率I2C通信的时钟速率应符合以下要求:- 标准模式(Standard Mode):时钟速率不超过100kHz。
- 快速模式(Fast Mode):时钟速率不超过400kHz。
- 高速模式(High-Speed Mode):时钟速率不超过3.4MHz。
- 超高速模式(Ultra Fast Mode):时钟速率不超过5MHz。
5. 数据传输格式5.1 帧结构I2C通信使用帧结构进行数据传输,一个帧包含以下要素:- 起始位(Start Bit):逻辑低电平表示传输开始。
- 设备地址(Device Address):用于识别从设备的惟一地址。
- 读/写位(R/W Bit):逻辑低电平表示主设备发送数据,逻辑高电平表示主设备接收数据。
I2C通讯协议
I2C通讯协议协议名称:I2C通讯协议一、引言I2C(Inter-Integrated Circuit)通讯协议是一种串行通信协议,用于在集成电路(IC)之间进行数据传输。
本协议旨在定义I2C通讯的标准规范,以确保不同厂商的设备能够互相兼容并正确地进行通信。
二、术语定义在本协议中,以下术语定义适用:1. 主设备(Master):发起I2C通讯的设备,负责控制总线的访问和数据传输。
2. 从设备(Slave):响应I2C通讯的设备,根据主设备的指令进行数据传输。
3. 传输速率(Transfer Rate):数据在I2C总线上传输的速度,通常以kHz为单位。
4. 起始条件(Start Condition):主设备向从设备发送通信请求的信号。
5. 停止条件(Stop Condition):主设备结束通信的信号。
6. 读操作(Read Operation):主设备从从设备读取数据的操作。
7. 写操作(Write Operation):主设备向从设备发送数据的操作。
8. 寄存器(Register):从设备中用于存储数据的内部存储单元。
三、物理层规范1. 电气特性a. 通信线:使用双线制,包括一个时钟线(SCL)和一个数据线(SDA)。
b. 电压水平:SCL和SDA线的电压范围为0V至Vcc,其中Vcc为供电电压。
c. 上拉电阻:SCL和SDA线上需连接上拉电阻,以确保线路处于高电平状态。
d. 输入/输出电平:SCL和SDA线上的输入/输出电平应符合标准CMOS逻辑电平。
2. 时序特性a. 起始条件:在通信开始之前,主设备将SCL线保持高电平,然后将SDA线从高电平切换到低电平。
b. 停止条件:在通信结束时,主设备将SCL线保持高电平,然后将SDA线从低电平切换到高电平。
c. 数据传输:数据在SCL线的时钟信号下,从设备在SDA线上传输,每个数据位在一个时钟周期内进行。
d. 时钟频率:通信的时钟频率由主设备控制,典型频率为100 kHz或400 kHz。
I2C通讯协议
I2C通讯协议协议名称:I2C通讯协议一、引言I2C(Inter-Integrated Circuit)通讯协议是一种串行通信协议,用于在集成电路(IC)之间进行数据传输。
本协议旨在规范I2C通讯的数据格式、传输速率、地址分配和错误处理等方面的要求,以确保不同设备之间的互操作性和数据的可靠传输。
二、范围本协议适用于使用I2C通讯协议进行数据传输的所有设备,包括但不限于芯片、传感器、模块等。
三、术语定义1. 主设备(Master):发起I2C通讯的设备。
2. 从设备(Slave):响应I2C通讯的设备。
3. 传输速率(Bit Rate):数据传输的速度,单位为bps。
4. 起始条件(Start Condition):主设备发出的开始信号,表示I2C通讯的开始。
5. 停止条件(Stop Condition):主设备发出的停止信号,表示I2C通讯的结束。
6. 传输字节(Data Byte):在I2C通讯中传输的8位数据。
7. 地址(Address):从设备的唯一标识,用于选择通讯对象。
四、通讯流程1. 主设备发起通讯:a) 主设备发送起始条件。
b) 主设备发送从设备地址和读写位(R/W)。
c) 主设备等待从设备的应答信号。
d) 从设备应答后,主设备继续发送数据或接收数据。
2. 从设备响应通讯:a) 从设备接收起始条件。
b) 从设备接收自身地址和读写位(R/W)。
c) 从设备发送应答信号。
d) 主设备发送或接收数据。
五、数据格式1. 起始条件和停止条件:a) 起始条件:SDA(串行数据线)从高电平跳变到低电平,同时SCL(串行时钟线)保持高电平。
b) 停止条件:SDA从低电平跳变到高电平,同时SCL保持高电平。
2. 传输字节格式:a) 数据传输是以字节为单位进行的,每个字节由8位二进制数据组成。
b) 数据传输的最高位为起始位(Start Bit),接下来是7位数据位(D7-D1),最低位为停止位(Stop Bit)。
I2c总线协议
1.I2C协议2条双向串行线,一条数据线SDA,一条时钟线SCL。
SDA传输数据是大端传输,每次传输8bit,即一字节。
支持多主控(multimastering),任何时间点只能有一个主控。
总线上每个设备都有自己的一个addr,共7个bit,广播地址全0.系统中可能有多个同种芯片,为此addr分为固定部分和可编程部份,细节视芯片而定,看datasheet。
1.1 I2C位传输数据传输:SCL为高电平时,SDA线若保持稳定,那么SDA上是在传输数据bit;若SDA发生跳变,则用来表示一个会话的开始或结束(后面讲)数据改变:SCL为低电平时,SDA线才能改变传输的bit1.2 I2C开始和结束信号开始信号:SCL为高电平时,SDA由高电平向低电平跳变,开始传送数据。
结束信号:SCL为高电平时,SDA由低电平向高电平跳变,结束传送数据。
1.3 I2C应答信号Master每发送完8bit数据后等待Slave的ACK。
即在第9个clock,若从IC发ACK,SDA会被拉低。
若没有ACK,SDA会被置高,这会引起Master发生RESTART或STOP流程,如下所示:1.4 I2C写流程写寄存器的标准流程为:1. Master发起START2. Master发送I2C addr(7bit)和w操作0(1bit),等待ACK3. Slave发送ACK4. Master发送reg addr(8bit),等待ACK5. Slave发送ACK6. Master发送data(8bit),即要写入寄存器中的数据,等待ACK7. Slave发送ACK8.第6步和第7步可以重复多次,即顺序写多个寄存器9. Master发起STOP写一个寄存器写多个寄存器1.5 I2C读流程读寄存器的标准流程为:1. Master发送I2C addr(7bit)和w操作1(1bit),等待ACK2. Slave发送ACK3. Master发送reg addr(8bit),等待ACK4. Slave发送ACK5. Master发起START6. Master发送I2C addr(7bit)和r操作1(1bit),等待ACK7. Slave发送ACK8. Slave发送data(8bit),即寄存器里的值9. Master发送ACK10.第8步和第9步可以重复多次,即顺序读多个寄存器读一个寄存器读多个寄存器2. PowerPC的I2C实现Mpc8560的CCSR中控制I2C的寄存器共有6个。
(完整版)I2C总线协议及工作原理
I2C 总线协议及工作原理一、概括1、 I2C 总线只有两根双向信号线。
一根是数据线SDA ,另一根是时钟线SCL 。
SCL :上涨沿将数据输入到每个 EEPROM 器件中;降落沿驱动 EEPROM 器件输出数据。
(边缘触发 )SDA :双向数据线,为OD 门,与其余随意数目的OD 与 OC 门成 " 线与 " 关系。
I2C 总线经过上拉电阻接正电源。
当总线安闲时,两根线均为高电平(SDL=1;SCL=1 )。
连到总线上的任一器件输出的低电平,都将使总线的信号变低,即各器件的 SDA 及 SCL 都是线“与”关系。
2、主设施与从设施系统中的全部外头器件都拥有一个 7 位的 "从器件专用地点码 " ,此中高 4 位为器件种类,由生产厂家拟订,低 3 位为器件引脚定义地点,由使用者定义。
主控器件经过地点码成立多机通讯的体制,所以 I2C 总线省去了外头器件的片选线,这样不论总线上挂接多少个器件,其系统仍旧为简洁的二线构造。
终端挂载在总线上,有主端和从端之分,主端一定是带有CPU 的逻辑模块,在同一总线上同一时辰使能有一个主端,能够有多个从端,从端的数目受地点空间和总线的最大电容400pF 的限制。
主端主要用来驱动SCL line ;从设施对主设施产生响应;两者都能够传输数据,可是从设施不可以倡始传输,且传输是遇到主设施控制的。
二、协议1.安闲状态I2C 总线总线的SDA 和 SCL 两条信号线同时处于高电平常,规定为总线的安闲状态。
此时各个器件的输出级场效应管均处在截止状态,即开释总线,由两条信号线各自的上拉电阻把电平拉高。
2.开端位与停止位的定义:开端信号:当 SCL 为高时期, SDA 由高到低的跳变;启动信号是一种电平跳变时序信号,而不是一个电平信号。
停止信号:当 SCL 为高时期, SDA 由低到高的跳变;停止信号也是一种电平跳变时序信号,而不是一个电平信号。
I2C详解
I2C详解1 I2C接口简介I2C全称:Inter-Integrated Circuit,是一种同步、半双工的通信总线。
同步:发送接收端要严格同步,一般有同步时钟线。
半双工:I2C只有一条数据线,所以master发数据与收数据不能同时进行。
I2C通信速率:模式速率标准模式100 kbps快速模式400 kbps高速模式3.4 MbpsI2C诞生的背景:最初的嵌入系统是使用内存映射(memory-mapped I/O)的方式来互连微控制器和外围设备的。
要实现内存映射,设备必须并行连入微控制器的数据线和地址线,也就意味着:如果要连接一款新的外围设备,需在设计芯片时候确定好。
所以很不灵活并且成本高。
1982年,Philips实验室开发了I2C,方便CPU与外设之间通信。
1.1 I2C原理简介我理解的是:I2C设计时的理念是:信号线尽量少并且速率要尽量高。
信号线少,可以减少引脚占用,这对早期的芯片(引脚很少)的很重要。
当然,如果单纯说减少信号线,1-wire总线只使用1根线通信(比如DS18B20、DHT11等都是使用这种协议),但是1-wire总线是异步通信,所以1-wire总线速率不可能太高(1-wire总线传输速率一般为16.3Kbit/s,最大可达142 Kbit/s,通常情况下采用100Kbit/s 以下的速率传输数据)。
标准的I2C需要两根信号线:SCL(Serial Clock):时钟线,时钟都是有master提供的SDA(Serial Data):双向数据线,发数据或者收数据(收发不能同时)I2C多master多slave示意图:图中是2个master+2个slave的示意,同一时刻只有一个master 与一个slave通信。
若想实现这个效果:1 多个master-slave 时钟、数据线连在一起,需要实现信号的“线与”逻辑(所以SDA、SCL 被设计为漏极开路结构,外加上拉电阻实现“线与”)2 需要实现“时钟同步”和“总线仲裁”,引脚在输出信号的同时还能对引脚上的电平进行检测,检测是否与刚才输出一致,为“时钟同步”和“总线仲裁”提供硬件基础。
i2c协议电平
i2c协议电平I2C协议电平I2C(Inter-Integrated Circuit)是一种串行通信协议,广泛应用于各种电子设备之间的通信。
它采用两根传输线,一根是数据线(SDA),另一根是时钟线(SCL)。
在I2C通信中,数据的传输是基于电平的变化来实现的。
本文将详细介绍I2C协议电平的相关内容。
1. I2C电平标准在I2C通信中,数据线和时钟线的电平标准是非常重要的。
根据I2C规范,数据线和时钟线都是双向的,因此需要采用开漏输出的方式来控制电平。
通常情况下,I2C设备的输出电平为高阻态,而当需要输出低电平时,会拉低对应的数据线或时钟线。
2. I2C电平逻辑I2C协议使用的是双向通信,因此需要有一套特定的电平逻辑来表示不同的状态。
在I2C通信中,高电平表示逻辑1,低电平表示逻辑0。
当设备处于空闲状态时,数据线和时钟线都会保持高电平状态。
3. I2C起始信号和停止信号在I2C通信中,起始信号和停止信号的电平变化非常重要。
起始信号是由高电平到低电平的一个下降沿,而停止信号则是由低电平到高电平的一个上升沿。
在传输数据之前,发送方会先发送起始信号,表示数据传输的开始。
而在数据传输结束后,发送方会发送停止信号,表示数据传输的结束。
4. I2C数据传输在I2C通信中,数据的传输分为读和写两种方式。
在写数据时,发送方会先发送设备地址和写命令,然后发送具体的数据。
而在读数据时,发送方会先发送设备地址和读命令,然后接收方会返回相应的数据。
5. I2C数据确认在I2C通信中,数据的确认非常重要。
在发送每个字节的最后一位之后,接收方会发送一个ACK(Acknowledge)信号,用于确认数据的接收情况。
如果接收方成功接收到数据,则会发送一个低电平的ACK信号,而如果接收方未成功接收到数据,则会发送一个高电平的NACK(Not Acknowledge)信号。
6. I2C速度控制I2C通信的速度是可以通过控制时钟频率来实现的。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
THE I 2C-BUS SPECIFICATIONVERSION 2.1JANUARY 2000CONTENTS1PREFACE. . . . . . . . . . . . . . . . . . . . . . . . . . .3 1.1Version 1.0 - 1992. . . . . . . . . . . . . . . . . . . . 3 1.2Version 2.0 - 198. . . . . . . . . . . . . . . . . . . . . 3 1.3Version 2.1 - 1999. . . . . . . . . . . . . . . . . . . . 3 1.4Purchase of Philips I2C-bus components . . 3 2THE I2C-BUS BENEFITS DESIGNERSAND MANUFACTURERS. . . . . . . . . . . . . . .4 2.1Designer benefits . . . . . . . . . . . . . . . . . . . . 4 2.2Manufacturer benefits. . . . . . . . . . . . . . . . . 6 3INTRODUCTION TO THE I2C-BUSSPECIFICATION . . . . . . . . . . . . . . . . . . . . .6 4THE I2C-BUS CONCEPT . . . . . . . . . . . . . . .6 5GENERAL CHARACTERISTICS . . . . . . . . .8 6BIT TRANSFER . . . . . . . . . . . . . . . . . . . . . .8 6.1Data validity . . . . . . . . . . . . . . . . . . . . . . . . 8 6.2START and STOP conditions. . . . . . . . . . . 9 7TRANSFERRING DATA. . . . . . . . . . . . . . .10 7.1Byte format . . . . . . . . . . . . . . . . . . . . . . . . 10 7.2Acknowledge. . . . . . . . . . . . . . . . . . . . . . . 10 8ARBITRATION AND CLOCKGENERATION . . . . . . . . . . . . . . . . . . . . . .11 8.1Synchronization . . . . . . . . . . . . . . . . . . . . 11 8.2Arbitration . . . . . . . . . . . . . . . . . . . . . . . . . 12 8.3Use of the clock synchronizingmechanism as a handshake. . . . . . . . . . . 13 9FORMATS WITH 7-BIT ADDRESSES. . . .13 107-BIT ADDRESSING . . . . . . . . . . . . . . . . .15 10.1Definition of bits in the first byte . . . . . . . . 15 10.1.1General call address. . . . . . . . . . . . . . . . . 16 10.1.2START byte . . . . . . . . . . . . . . . . . . . . . . . 17 10.1.3CBUS compatibility. . . . . . . . . . . . . . . . . . 18 11EXTENSIONS TO THE STANDARD-MODE I2C-BUS SPECIFICATION . . . . . . .19 12FAST-MODE. . . . . . . . . . . . . . . . . . . . . . . .19 13Hs-MODE . . . . . . . . . . . . . . . . . . . . . . . . . .20 13.1High speed transfer. . . . . . . . . . . . . . . . . . 20 13.2Serial data transfer format in Hs-mode. . . 21 13.3Switching from F/S- to Hs-mode andback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2313.4Hs-mode devices at lower speed modes. . 24 13.5Mixed speed modes on one serial bussystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 13.5.1F/S-mode transfer in a mixed-speed bussystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 13.5.2Hs-mode transfer in a mixed-speed bussystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 13.5.3Timing requirements for the bridge in amixed-speed bus system. . . . . . . . . . . . . . 27 1410-BIT ADDRESSING. . . . . . . . . . . . . . . . 27 14.1Definition of bits in the first two bytes. . . . . 27 14.2Formats with 10-bit addresses. . . . . . . . . . 27 14.3General call address and start byte with10-bit addressing. . . . . . . . . . . . . . . . . . . . 30 15ELECTRICAL SPECIFICATIONSAND TIMING FOR I/O STAGESAND BUS LINES. . . . . . . . . . . . . . . . . . . . 30 15.1Standard- and Fast-mode devices. . . . . . . 30 15.2Hs-mode devices. . . . . . . . . . . . . . . . . . . . 34 16ELECTRICAL CONNECTIONS OFI2C-BUS DEVICES TO THE BUS LINES . 37 16.1Maximum and minimum values ofresistors R p and R s for Standard-modeI2C-bus devices . . . . . . . . . . . . . . . . . . . . . 39 17APPLICATION INFORMATION. . . . . . . . . 41 17.1Slope-controlled output stages ofFast-mode I2C-bus devices. . . . . . . . . . . . 41 17.2Switched pull-up circuit for Fast-modeI2C-bus devices . . . . . . . . . . . . . . . . . . . . . 41 17.3Wiring pattern of the bus lines. . . . . . . . . . 42 17.4Maximum and minimum values ofresistors R p and R s for Fast-modeI2C-bus devices . . . . . . . . . . . . . . . . . . . . . 42 17.5Maximum and minimum values ofresistors R p and R s for Hs-modeI2C-bus devices . . . . . . . . . . . . . . . . . . . . . 42 18BI-DIRECTIONAL LEVEL SHIFTERFOR F/S-MODE I2C-BUS SYSTEMS . . . . 42 18.1Connecting devices with differentlogic levels. . . . . . . . . . . . . . . . . . . . . . . . . 43 18.1.1Operation of the level shifter . . . . . . . . . . . 44 19DEVELOPMENT TOOLS AVAILABLEFROM PHILIPS. . . . . . . . . . . . . . . . . . . . . 45 20SUPPORT LITERATURE . . . . . . . . . . . . . 461PREFACE1.1Version 1.0 - 1992This version of the 1992 I2C-bus specification includes the following modifications:•Programming of a slave address by software has been omitted. The realization of this feature is rather complicated and has not been used.•The “low-speed mode” has been omitted. This mode is, in fact, a subset of the total I2C-bus specification and need not be specified explicitly.•The Fast-mode is added. This allows a fourfold increase of the bit rate up to 400kbit/s. Fast-mode devices are downwards compatible i.e. they can be used in a 0 to 100kbit/s I2C-bus system.•10-bit addressing is added. This allows 1024 additional slave addresses.•Slope control and input filtering for Fast-mode devices is specified to improve the EMC behaviour.NOTE: Neither the 100kbit/s I2C-bus system nor the 100kbit/s devices have been changed.1.2Version2.0 - 1998The I2C-bus has become a de facto world standard that is now implemented in over 1000 different ICs and licensed to more than 50 companies. Many of today’s applications, however, require higher bus speeds and lower supply voltages. This updated version of the I2C-bus specification meets those requirements and includes the following modifications:•The High-speed mode (Hs-mode) is added. This allows an increase in the bit rate up to 3.4Mbit/s. Hs-mode devices can be mixed with Fast- and Standard-mode devices on the one I2C-bus system with bit rates from 0 to 3.4Mbit/s.•The low output level and hysteresis of devices with a supply voltage of 2V and below has been adapted to meet the required noise margins and to remain compatible with higher supply voltage devices.•The 0.6V at 6mA requirement for the output stages of Fast-mode devices has been omitted.•The fixed input levels for new devices are replaced by bus voltage-related levels.•Application information for bi-directional level shifter is added.1.3Version2.1 - 2000Version 2.1 of the I2C-bus specification includes the following minor modifications:•After a repeated START condition in Hs-mode, it is possible to stretch the clock signal SCLH (see Section13.2 and Figs22, 25 and 32).•Some timing parameters in Hs-mode have been relaxed (see Tables6 and 7).1.4Purchase of Philips I2C-bus componentsPurchase of Philips I2C components conveys a license under the Philips’ I2C patent to use thecomponents in the I2C system provided the system conforms to the I2C specification defined byPhilips.2THE I2C-BUS BENEFITS DESIGNERS AND MANUFACTURERSIn consumer electronics, telecommunications and industrial electronics, there are often many similarities between seemingly unrelated designs. For example, nearly every system includes:•Some intelligent control, usually a single-chip microcontroller•General-purpose circuits like LCD drivers, remote I/O ports, RAM, EEPROM, or data converters•Application-oriented circuits such as digital tuning and signal processing circuits for radio and video systems, or DTMF generators for telephones with tone dialling.To exploit these similarities to the benefit of both systems designers and equipment manufacturers, as well as to maximize hardware efficiency and circuit simplicity, Philips developed a simple bi-directional 2-wire bus for efficient inter-IC control. This bus is called the Inter IC or I2C-bus. At present, Philips’ IC range includes more than 150 CMOS and bipolar I2C-bus compatible types for performing functions in all three of the previously mentioned categories. All I2C-bus compatible devices incorporate an on-chip interface which allows them to communicate directly with each other via the I2C-bus. This design concept solves the many interfacing problems encountered when designing digital control circuits.Here are some of the features of the I2C-bus:•Only two bus lines are required; a serial data line (SDA) and a serial clock line (SCL)•Each device connected to the bus is software addressable by a unique address and simplemaster/slave relationships exist at all times; masters can operate as master-transmitters or as master-receivers•It’s a true multi-master bus including collision detection and arbitration to prevent data corruption if two or more masters simultaneously initiate data transfer•Serial, 8-bit oriented, bi-directional data transfers can be made at up to 100kbit/s in the Standard-mode, up to 400kbit/s in the Fast-mode, or up to 3.4Mbit/s in the High-speed mode•On-chip filtering rejects spikes on the bus data line to preserve data integrity •The number of ICs that can be connected to the same bus is limited only by a maximum bus capacitance of 400pF.Figure1 shows two examples of I2C-bus applications. 2.1Designer benefitsI2C-bus compatible ICs allow a system design to rapidly progress directly from a functional block diagram to a prototype. Moreover, since they ‘clip’ directly onto theI2C-bus without any additional external interfacing, they allow a prototype system to be modified or upgraded simply by ‘clipping’ or ‘unclipping’ ICs to or from the bus. Here are some of the features of I2C-bus compatible ICs which are particularly attractive to designers:•Functional blocks on the block diagram correspond with the actual ICs; designs proceed rapidly from block diagram to final schematic.•No need to design bus interfaces because the I2C-bus interface is already integrated on-chip.•Integrated addressing and data-transfer protocol allow systems to be completely software-defined•The same IC types can often be used in many different applications•Design-time reduces as designers quickly become familiar with the frequently used functional blocks represented by I2C-bus compatible ICs•ICs can be added to or removed from a system without affecting any other circuits on the bus•Fault diagnosis and debugging are simple; malfunctions can be immediately traced•Software development time can be reduced by assembling a library of reusable software modules.In addition to these advantages, the CMOS ICs in theI2C-bus compatible range offer designers special features which are particularly attractive for portable equipment and battery-backed systems.They all have:•Extremely low current consumption•High noise immunity•Wide supply voltage range•Wide operating temperature range.Fig.1 Two examples of I 2C-bus applications: (a) a high performance highly-integrated TV set(b) DECT cordless phone base-station.handbook, full pagewidthSDA SCLMICRO-CONTROLLER PCB83C528PLLSYNTHESIZERTSA5512NON-VOLATILE MEMORY PCF8582ESTEREO / DUAL SOUND DECODER TDA9840HI-FI AUDIOPROCESSOR TDA9860SINGLE-CHIP TEXT SAA52XXM/S COLOUR DECODER TDA9160APICTURE SIGNALIMPROVEMENTTDA4670VIDEOPROCESSORTDA4685ON-SCREENDISPLAYPCA8510(a)MSB575SDASCLLINEINTERFACEPCA1070BURST MODE CONTROLLERPCD5042ADPCMPCD5032(b)DTMFGENERATOR PCD3311MICRO-CONTROLLER P80CLXXX2.2Manufacturer benefitsI2C-bus compatible ICs don’t only assist designers, they also give a wide range of benefits to equipment manufacturers because:•The simple 2-wire serial I2C-bus minimizes interconnections so ICs have fewer pins and there are not so many PCB tracks; result - smaller and less expensive PCBs•The completely integrated I2C-bus protocol eliminates the need for address decoders and other ‘glue logic’•The multi-master capability of the I2C-bus allows rapid testing and alignment of end-user equipment via external connections to an assembly-line•The availability of I2C-bus compatible ICs in SO (small outline), VSO (very small outline) as well as DIL packages reduces space requirements even more. These are just some of the benefits. In addition, I2C-bus compatible ICs increase system design flexibility by allowing simple construction of equipment variants and easy upgrading to keep designs up-to-date. In this way, an entire family of equipment can be developed around a basic model. Upgrades for new equipment, or enhanced-feature models (i.e. extended memory, remote control, etc.) can then be produced simply by clipping the appropriate ICs onto the bus. If a larger ROM is needed, it’s simply a matter of selecting a micro-controller with a larger ROM from our comprehensive range. As new ICs supersede older ones, it’s easy to add new features to equipment or to increase its performance by simply unclipping the outdated IC from the bus and clipping on its successor.3INTRODUCTION TO THE I2C-BUS SPECIFICATION For 8-bit oriented digital control applications, such as those requiring microcontrollers, certain design criteria can be established:•A complete system usually consists of at least one microcontroller and other peripheral devices such as memories and I/O expanders•The cost of connecting the various devices within the system must be minimized •A system that performs a control function doesn’t require high-speed data transfer•Overall efficiency depends on the devices chosen and the nature of the interconnecting bus structure.To produce a system to satisfy these criteria, a serial bus structure is needed. Although serial buses don’t have the throughput capability of parallel buses, they do require less wiring and fewer IC connecting pins. However, a bus is not merely an interconnecting wire, it embodies all the formats and procedures for communication within the system.Devices communicating with each other on a serial bus must have some form of protocol which avoids all possibilities of confusion, data loss and blockage of information. Fast devices must be able to communicate with slow devices. The system must not be dependent on the devices connected to it, otherwise modifications or improvements would be impossible. A procedure has also to be devised to decide which device will be in control of the bus and when. And, if different devices with different clock speeds are connected to the bus, the bus clock source must be defined. All these criteria are involved in the specification of the I2C-bus.4THE I2C-BUS CONCEPTThe I2C-bus supports any IC fabrication process (NMOS, CMOS, bipolar). Two wires, serial data (SDA) and serial clock (SCL), carry information between the devices connected to the bus. Each device is recognized by a unique address (whether it’s a microcontroller, LCD driver, memory or keyboard interface) and can operate as either a transmitter or receiver, depending on the function of the device. Obviously an LCD driver is only a receiver, whereas a memory can both receive and transmit data. In addition to transmitters and receivers, devices can also be considered as masters or slaves when performing data transfers (see Table 1). A master is the device which initiates a data transfer on the bus and generates the clock signals to permit that transfer. At that time, any device addressed is considered a slave.Table 1Definition of I 2C-bus terminologyThe I 2C-bus is a multi-master bus. This means that more than one device capable of controlling the bus can be connected to it. As masters are usually micro-controllers, let’s consider the case of a data transfer between two microcontrollers connected to the I 2C-bus (see Fig.2). This highlights the master-slave and receiver-transmitter relationships to be found on the I 2C-bus. It should be noted that these relationships are not permanent, but onlydepend on the direction of data transfer at that time. The transfer of data would proceed as follows:1) Suppose microcontroller A wants to send information to microcontroller B:•microcontroller A (master), addresses microcontroller B (slave)•microcontroller A (master-transmitter), sends data to microcontroller B (slave- receiver)•microcontroller A terminates the transfer2) If microcontroller A wants to receive information from microcontroller B:•microcontroller A (master) addresses microcontroller B (slave)•microcontroller A (master- receiver) receives data from microcontroller B (slave- transmitter)•microcontroller A terminates the transfer.Even in this case, the master (microcontroller A) generates the timing and terminates the transfer.The possibility of connecting more than onemicrocontroller to the I 2C-bus means that more than one master could try to initiate a data transfer at the same time. To avoid the chaos that might ensue from such an event - an arbitration procedure has been developed. Thisprocedure relies on the wired-AND connection of all I 2C interfaces to the I 2C-bus.If two or more masters try to put information onto the bus, the first to produce a ‘one’ when the other produces a ‘zero’ will lose the arbitration. The clock signals during arbitration are a synchronized combination of the clocks generated by the masters using the wired-AND connection to the SCL line (for more detailed information concerning arbitration see Section 8).TERM DESCRIPTIONT ransmitter The device which sends data to the busReceiver The device which receives data from the busMasterThe device which initiates a transfer, generates clock signals and terminates a transferSlave The device addressed by a master Multi-masterMore than one master can attempt to control the bus at the same time without corrupting the message ArbitrationProcedure to ensure that, if more than one master simultaneously tries to control the bus, only one is allowed to do so and the winning message is not corruptedSynchronizationProcedure to synchronize the clock signals of two or more devicesFig.2 Example of an I 2C-bus configuration using two microcontrollers.MBC645SDA SCLMICRO -CONTROLLER ASTATIC RAM OR EEPROMLCD DRIVERGATE ARRAYADCMICRO -CONTROLLER BGeneration of clock signals on the I 2C-bus is always the responsibility of master devices; each master generates its own clock signals when transferring data on the bus. Bus clock signals from a master can only be altered when they are stretched by a slow-slave device holding-down the clock line, or by another master when arbitration occurs.5GENERAL CHARACTERISTICSBoth SDA and SCL are bi-directional lines, connected to a positive supply voltage via a current-source or pull-up resistor (see Fig.3). When the bus is free, both lines are HIGH. The output stages of devices connected to the bus must have an open-drain or open-collector to perform the wired-AND function. Data on the I 2C-bus can be transferred at rates of up to 100kbit/s in theStandard-mode, up to 400kbit/s in the Fast-mode, or up to 3.4Mbit/s in the High-speed mode. The number ofinterfaces connected to the bus is solely dependent on the bus capacitance limit of 400pF. For information on High-speed mode master devices, see Section 13.6BIT TRANSFERDue to the variety of different technology devices (CMOS, NMOS, bipolar) which can be connected to the I 2C-bus, the levels of the logical ‘0’ (LOW) and ‘1’ (HIGH) are not fixed and depend on the associated level of V DD (see Section 15 for electrical specifications). One clock pulse is generated for each data bit transferred.6.1Data validityThe data on the SDA line must be stable during the HIGH period of the clock. The HIGH or LOW state of the data line can only change when the clock signal on the SCL line is LOW (see Fig.4).Fig.3 Connection of Standard- and Fast-mode devices to the I 2C-bus.MBC631SCLKN1OUT SCLK INSCLKDATAN1OUT DATA IN DEVICE 1SDA (Serial Data Line)SCL (Serial Clock Line)SCLKN2OUT SCLK INSCLK DATAN2OUT DATA IN DEVICE 2V DDR pR ppull-up resistorsFig.4 Bit transfer on the I 2C-bus.handbook, full pagewidthMBC621data line stable;data validchange of data allowedSDASCL6.2START and STOP conditionsWithin the procedure of the I 2C-bus, unique situations arise which are defined as START (S) and STOP (P) conditions (see Fig.5).A HIGH to LOW transition on the SDA line while SCL is HIGH is one such unique case. This situation indicates a START condition.A LOW to HIGH transition on the SDA line while SCL is HIGH defines a STOP condition.START and STOP conditions are always generated by the master. The bus is considered to be busy after the START condition. The bus is considered to be free again a certain time after the STOP condition. This bus free situation is specified in Section 15.The bus stays busy if a repeated START (Sr) is generated instead of a STOP condition. In this respect, the START (S) and repeated START (Sr) conditions are functionally identical (see Fig. 10). For the remainder of this document, therefore, the S symbol will be used as a generic term to represent both the START and repeated START conditions, unless Sr is particularly relevant.Detection of START and STOP conditions by devices connected to the bus is easy if they incorporate the necessary interfacing hardware. However,microcontrollers with no such interface have to sample the SDA line at least twice per clock period to sense the transition.Fig.5 START and STOP conditions.handbook, full pagewidthMBC622SDA SCLPSTOP conditionSDASCLSSTART condition7TRANSFERRING DATA 7.1Byte formatEvery byte put on the SDA line must be 8-bits long. The number of bytes that can be transmitted per transfer is unrestricted. Each byte has to be followed by an acknowledge bit. Data is transferred with the most significant bit (MSB) first (see Fig.6). If a slave can’t receive or transmit another complete byte of data until it has performed some other function, for example servicing an internal interrupt, it can hold the clock line SCL LOW to force the master into a wait state. Data transfer thencontinues when the slave is ready for another byte of data and releases clock line SCL.In some cases, it’s permitted to use a different format from the I 2C-bus format (for CBUS compatible devices for example). A message which starts with such an address can be terminated by generation of a STOP condition, even during the transmission of a byte. In this case, no acknowledge is generated (see Section 10.1.3).7.2AcknowledgeData transfer with acknowledge is obligatory. The acknowledge-related clock pulse is generated by the master. The transmitter releases the SDA line (HIGH) during the acknowledge clock pulse.The receiver must pull down the SDA line during the acknowledge clock pulse so that it remains stable LOWduring the HIGH period of this clock pulse (see Fig.7). Of course, set-up and hold times (specified in Section 15) must also be taken into account.Usually, a receiver which has been addressed is obliged to generate an acknowledge after each byte has been received, except when the message starts with a CBUS address (see Section 10.1.3).When a slave doesn’t acknowledge the slave address (for example, it’s unable to receive or transmit because it’s performing some real-time function), the data line must be left HIGH by the slave. The master can then generate either a STOP condition to abort the transfer, or a repeated START condition to start a new transfer.If a slave-receiver does acknowledge the slave address but, some time later in the transfer cannot receive any more data bytes, the master must again abort the transfer. This is indicated by the slave generating thenot-acknowledge on the first byte to follow. The slave leaves the data line HIGH and the master generates a STOP or a repeated START condition.If a master-receiver is involved in a transfer, it must signal the end of data to the slave- transmitter by not generating an acknowledge on the last byte that was clocked out of the slave. The slave-transmitter must release the data line to allow the master to generate a STOP or repeated START condition.Fig.6 Data transfer on the I 2C-bus.handbook, full pagewidthMSC608Sr or PSDASrPSCLSTOP or repeated STARTconditionS or SrSTART or repeated STARTcondition12 3 - 89ACK9ACK7812MSBacknowledgement signal from slavebyte complete,interrupt within slaveclock line held low while interrupts are servicedacknowledgement signal from receiverFig.7 Acknowledge on the I 2C-bus.handbook, full pagewidthMBC602S START condition9821clock pulse for acknowledgementnot acknowledgeacknowledgeDATA OUTPUT BY TRANSMITTERDATA OUTPUT BY RECEIVERSCL FROM MASTER8ARBITRATION AND CLOCK GENERATION 8.1SynchronizationAll masters generate their own clock on the SCL line to transfer messages on the I 2C-bus. Data is only valid during the HIGH period of the clock. A defined clock is therefore needed for the bit-by-bit arbitration procedure to take place.Clock synchronization is performed using the wired-AND connection of I 2C interfaces to the SCL line. This meansthat a HIGH to LOW transition on the SCL line will cause the devices concerned to start counting off their LOW period and, once a device clock has gone LOW, it will hold the SCL line in that state until the clock HIGH state is reached (see Fig.8). However, the LOW to HIGH transition of this clock may not change the state of the SCL line if another clock is still within its LOW period. The SCL line will therefore be held LOW by the device with the longest LOW period. Devices with shorter LOW periods enter a HIGH wait-state during this time.Fig.8 Clock synchronization during the arbitration procedure.CLK 1CLK 2SCLcounter resetwait statestart counting HIGH periodMBC632When all devices concerned have counted off their LOW period, the clock line will be released and go HIGH. There will then be no difference between the device clocks and the state of the SCL line, and all the devices will start counting their HIGH periods. The first device to complete its HIGH period will again pull the SCL line LOW.In this way, a synchronized SCL clock is generated with its LOW period determined by the device with the longest clock LOW period, and its HIGH period determined by the one with the shortest clock HIGH period.8.2ArbitrationA master may start a transfer only if the bus is free. Two or more masters may generate a START condition within the minimum hold time (t HD;STA ) of the START condition which results in a defined START condition to the bus.Arbitration takes place on the SDA line, while the SCL line is at the HIGH level, in such a way that the master which transmits a HIGH level, while another master istransmitting a LOW level will switch off its DATA output stage because the level on the bus doesn’t correspond to its own level.Arbitration can continue for many bits. Its first stage is comparison of the address bits (addressing information is given in Sections 10 and 14). If the masters are each tryingto address the same device, arbitration continues with comparison of the data-bits if they are master-transmitter, or acknowledge-bits if they are master-receiver. Because address and data information on the I 2C-bus is determined by the winning master, no information is lost during the arbitration process.A master that loses the arbitration can generate clock pulses until the end of the byte in which it loses the arbitration.As an Hs-mode master has a unique 8-bit master code, it will always finish the arbitration during the first byte (see Section 13).If a master also incorporates a slave function and it loses arbitration during the addressing stage, it’s possible that the winning master is trying to address it. The losingmaster must therefore switch over immediately to its slave mode.Figure 9 shows the arbitration procedure for two masters. Of course, more may be involved (depending on how many masters are connected to the bus). The moment there is a difference between the internal data level of the master generating DATA 1 and the actual level on the SDA line, its data output is switched off, which means that a HIGH output level is then connected to the bus. This will not affect the data transfer initiated by the winning master.Fig.9 Arbitration procedure of two masters.handbook, full pagewidthMSC609DATA 1DATA 2SDASCLSmaster 1 loses arbitrationDATA 1 SDA。