24.2 Architectural Overview
The I2C bus is a two-wire serial interface. Figure 24-1 illustrates the schematic of an I2C connection between a dsPIC33AK512MPS512 device and a 24LC256 I2C serial EEPROM, which is a typical example for any I2C interface.
The I2C interface uses a comprehensive protocol to ensure reliable transmission and reception of the data. When communicating, one device acts as the host, initiates transfer on the bus and generates the clock signals to permit that transfer, while the other devices act as the client responding to the transfer. The clock line, SCLx, is the output from the host and the input to the client, although occasionally the client drives the SCLx line. The data line, SDAx, may be the output and the input from both the host and client.
Because the SDAx and SCLx lines are bidirectional, the output stages of the devices driving the SDAx and SCLx lines must have an open-drain in order to perform the wired-AND function of the bus. External pull-up resistors are used to ensure a high level when no device is pulling the line down.
In the I2C interface protocol, each device has an address. When a host needs to initiate a data transfer, it first transmits the address of the device that it wants to communicate. All the devices listen to see if this is their address. Within this address, bit 0 specifies whether the host wants to read from or write to the client device. The host and client are always in opposite modes (Transmitter or Receiver) of operation during a data transfer. That is, they operate in either of the following two relationships:
- Host-transmitter and client-receiver
- Client-transmitter and host-receiver
In both cases, the host originates the SCLx clock signal.