i2c协议

 The I2C protocol.

A device that sends data onto the bus is defined as a transmitter and a device receiving data is a receiver.

The device that controls the message is called a master. The devices that are controlled by the master are referred to as slaves.

The bus must be controlled by a master device, which generates the serial clock (SCL), controls the bus access, and generates the START and STOP conditions.

Within the bus specifications, a standard mode (100kHz maximum clock rate)  and a fast mode (400kHz maximum clock rate) are defined.

Connections to the bus are made through the open-drain I/O lines SDA and SCL.

 The following bus protocol has been defined (Figure 5).

Data transfer can be initiated only when the bus is not busy.

During data transfer, the data line must remain stable whenever the clock line is HIGH.

Changes in the data line while the clock line is HIGH are interpreted as control signals.

Accordingly, the following bus conditions have been defined:
Bus not busy: Both data and clock lines remain HIGH.
Start data transfer: A change in the state of the data line, from HIGH to LOW, while the clock is HIGH, defines a START condition.
Stop data transfer: A change in the state of the data line, from LOW to HIGH, while the clock line is HIGH, defines the STOP condition.

Data valid: The state of the data line represents valid data when, after a START condition, the data line is stable for the duration of the HIGH period of the clock signal.

The data on the line must be changed during the LOW period of the clock signal. There is one clock pulse per bit of data.

Each data transfer is initiated with a START condition and terminated with a STOP condition.

The number of data bytes transferred between START and STOP conditions is not limited and is determined by the master device.

The information is transferred byte-wise and each receiver acknowledges with a ninth bit.

Acknowledge:  Each receiving device, when addressed, is obliged to generate an acknowledge after the reception

of each byte.

The master device must generate an extra clock pulse that is associated with this acknowledge bit.

A device that acknowledges must pull down the SDA line during the acknowledge clock pulse in such a way that the SDA line is stable LOW during the HIGH period of the acknowledge-related clock pulse.

Of course, setup and hold times must be taken into account.

A master must signal an end of data to the slave by not generating an acknowledge bit on the last byte that has been clocked out of the slave.

In this case, the slave must leave the data line HIGH to enable the master to generate the STOP condition. 

Depending upon the state of the R/W bit, two types of data transfer are possible:
 
1)  Data transfer from a master transmitter to a slave receiver. The master transmits the first byte (the slave address).

Next follows a number of data bytes. The slave returns an acknowledge bit after each received byte.
Data is transferred with the most significant bit (MSB) first.
 
2)  Data transfer from a slave transmitter to a master receiver. The master transmits the first byte (the slave address).

The slave then returns an acknowledge bit, which is followed by the slave transmitting a number of  data bytes.

The master returns an acknowledge bit after all received bytes other than the last byte.

At the end of the last received byte, a “not acknowledge” is returned.

The master device generates all of the serial clock pulses and the START and STOP conditions.

A transfer is ended with a STOP condition or with a repeated START condition.

Since a repeated START condition is also the beginning of the next serial transfer, the bus is not released.

Data is transferred with the most significant bit (MSB) first.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值