I2C
What is I2C?
A synchronous serial communication interface originally developed by Philips (now NXP), I2C (Inter-Integrated Circuit) enables data transmission synchronized with a clock.
I2C is commonly used for communication with EEPROMs, sensors, and peripheral devices, alongside SPI.
Communication is carried out using two signal lines: clock (SCL) and data input/output (SDA). Both lines utilize open drain communication, so pull-up resistors must be connected.
I2C follows a master-slave configuration, where the master issues instructions to the slave for sending/receiving data. The master also generates the clock signal to synchronize input/output.
Multiple slaves can be connected to one master.
The connection between master and slaves can be visualized as follows.
Communication Procedure
I2C communication follows a structured sequence of steps.
① The master initiates communication by sending a start signal (start condition)
② The master sends the address of the target slave device
③ The slave sends an acknowledgment (ACK) signal to the confirm reception
④ Data is exchanged (repeated as necessary)
⑤ The master sends a signal to stop communication (stop condition)
This procedure is shown in the following diagram.
Consider a scenario where the master transmits 1 byte of data (0x5A) to a slave device with address 0xA0.
Both the slave address and data are transmitted MSB first (from the most significant bit to the least significant bit), synchronized with SCL (clock). After transferring the slave address and each 8-bit data segment, the receiving device responds with an acknowledge signal (=0).
A start condition occurs when SDA falls while SCL is High, and stop condition when SDA rises while SCL is High. These signals notify the slave of the start and end of communication.
Transmitting Data from Master to Slave
Since multiple slaves can be connected to a single master, the master must notify the specific slave device it intends to communicate with. The slave address serves this purpose, with each slave device having a unique value.
After signaling the beginning of communication (start condition), the master sends the slave address, which is received by all connected slaves. The slave device with the matching address prepares for communication, while non-matching slaves enter a standby state.
The following diagram illustrates the process of transmitting one byte of data from the master to the slave.
If the least significant bit of the address is set to W (=0), it indicates that the master intends to send data to the slave.
Receiving Data from Slave to Master
The following diagram shows the process when the master receives one byte of data from the slave.
If the least significant bit is set R (=1) during slave address communication, the master intends to receive data from the slave.
For more details on I2C, please refer to the ‘I2C-bus specification and user manual’ on NXP’s website.