I2C匯流排是由Philips公司開發的一種簡單、雙向二線制同步串列匯流排。它只需要兩根線即可在連接於匯流排上的器件之間傳送信息。 To control multi-master IIC-bus operations, values must be written to the following reg ...
I2C匯流排是由Philips公司開發的一種簡單、雙向二線制同步串列匯流排。它只需要兩根線即可在連接於匯流排上的器件之間傳送信息。
To control multi-master IIC-bus operations, values must be written to the following registers:
— Multi-master IIC-bus control register, IICCON
— Multi-master IIC-bus control/status register, IICSTAT
— Multi-master IIC-bus Tx/Rx data shift register, IICDS
— Multi-master IIC-bus address register, IICADD
控制I2C匯流排,需要設置一下寄存器,IICCON IICSTAT IICDS IICADD
When the IIC-bus is free, the SDA and SCL lines should be both at High level. A High-to-Low transition of SDA
can initiate a Start condition. A Low-to-High transition of SDA can initiate a Stop condition while SCL remains
steady at High Level.
匯流排空閑時,SDA和SCL為高電平。當SCL為高電平時,SDA由高到低表示START信號,SDA由低到高表示STOP信號,如下圖所示
When a master initiates a Start condition, it should send a slave address to notify the slave device. One byte of
address field consists of a 7-bit address and a 1-bit transfer direction indicator (showing write or read).
If bit 8 is 0, it indicates a write operation (transmit operation); if bit 8 is 1, it indicates a request for data read
(receive operation).
當匯流排發出一個START信號後,匯流排需要傳輸一個7bit的從機地址和一位的讀寫位。0表示write,1表示read
例如:從機地址為0x68,需要執行的操作是讀,那麼需要發送的SLAVE_ADDRESS = (0x68 << 1) | 0x1;
Every byte placed on the SDA line should be eight bits in length. The bytes can be unlimitedly transmitted per
transfer. The first byte following a Start condition should have the address field. The address field can be
transmitted by the master when the IIC-bus is operating in Master mode. Each byte should be followed by an
acknowledgement (ACK) bit. The MSB bit of the serial data and addresses are always sent first.
i2c匯流排傳輸單位為byte,i2c每次傳輸完成後從設備都需要回覆一個ack信號,告知master設備數據已經接收完成,如下圖所示