UG-1262
Rev. B | Page 226 of 312
I
2
C SERIAL INTERFACE
I
2
C FEATURES
The I
2
C interface features master or slave mode with 2-byte transmit and receive FIFOs. The I
2
C interface supports 7-bit and 10-bit addressing
modes, either as four 7-bit device addresses or a combination of one 10-bit address and two 7-bit addresses in the slave with repeated
starts in master and slave modes. Other devices on the bus can enable clock stretching without causing any issues with the
Master arbitration, continuous read mode for the master or up to 512 bytes, fixed read, and internal and external loopback are also available.
Support for DMA in master and slave modes is provided by the DMA controller, as well as software control on the slave of the no
acknowledge signal.
I
2
C OVERVIEW
The I
2
C data transfer uses a serial clock pin (I2C_SCL) and a serial data pin (I2C_SDA). These pins are configured in a wire-AND’ed
gated format that allows arbitration in a multimaster system.
The transfer sequence of the I
2
C system is initiated by a master device, which generates a start condition while the bus is idle. The master
transmits the slave device address and the direction of the data transfer during the initial address transfer. If the master does not lose
arbitration and the slave acknowledges the initial address transfer, the data transfer is initiated. This transfer continues until the master
issues a stop condition and the bus becomes idle. Figure 57 shows a typical I
2
C transfer.
A master device can be configured to generate the serial clock. The frequency is programmed by the user in the serial clock divisor
register, DIV. The master channel can be set to operate in fast mode (400 kHz) or standard mode (100 kHz).
MSB
START
BIT
I2C_SCL
ACK
BIT
ACK
BIT
STOP
BIT
SLAVE ADDRESS
I2C_SDA
MSB
LSB
LSB
DATA
1
1
7
8
8
9
9
2
3 TO 6
2 TO 7
R/W
16
675-
139
Figure 57. Typical I
2
C Transfer Sequence
The user programs the I
2
C bus peripheral address in the I
2
C bus system. This ID can be modified any time a transfer is not in progress.
The user can set up to four slave addresses that are recognized by the peripheral. The peripheral is implemented with a 2-byte FIFO for
each transmit and receive shift register. The IRQ and status bits in the control registers are available to signal to the processor core when
the FIFOs need to be serviced.
I
2
C OPERATION
I
2
C Startup
The following steps are required to run the I
2
C peripheral:
1.
Enable PCLK to the I
2
C peripheral by setting CTL5, Bit 5 and CTL5, Bit 3 = 0. PCLK frequency is controlled via CTL1, Bits[13:8].
2.
Configure the digital pins (P0.4/I2C_SCL and P0.5/I2C_SDA) for I
2
C operation via the GP0CON register.
3.
Ensure the drive strength for the P0.4/I2C_SCL pin and P0.5/I2C_SDA pin is increased to ensure reliable I
2
C communications, as
detailed in the following example code:
GP0DS = 0x30; // Increase drive strength of I2C pins.
4.
Configure the I
2
C registers as required for slave or master operation.
5.
Enable the I
2
C slave or master interrupt source as required.
When using I
2
C, the user must disable the internal pull-up resistors on the I
2
C pins via the GP0POL register. The GPIO multiplexed
configuration mode is I2C_SCL for P0.4/I2C_SCL and is I2C_SDA for P0.5/I2C_SDA.
7-Bit Addressing
The ID0 register, ID1 register, ID2 register, and ID3 register contain the slave device IDs. The
compares the four IDx
registers to the address byte. To be correctly addressed, the seven MSBs of IDx registers must be identical to that of the seven MSBs of the
first received address byte. The LSB of the IDx registers (R/W or the transfer directional bit) is ignored in the process of address
recognition. The master addresses a device using the ADR1 register.