ADuCM320 Hardware Reference Manual
UG-498
Rev. C | Page 101 of 196
I
2
C SERIAL INTERFACE
I
2
C FEATURES
Master or slave mode with 2-byte transmit and receive FIFOs
Supports
o
7-bit and 10-bit addressing modes
o
Four 7-bit device addresses or one 10-bit address and two 7-bit addresses in the slave
o
Repeated starts in master and slave modes
o
Clock stretching can be enabled by other devices on the bus without causing any issues with the
; however, the
cannot enable clock stretching
o
Master arbitration
o
Continuous read mode for the master or up to 512 bytes fixed read
o
Internal and external loopback
Support for DMA in master and slave modes
Software control on the slave of NACK signal
I
2
C OVERVIEW
The I
2
C data transfer uses a serial clock pin (SCL) and a serial data pin (SDA). The pins are configured in a wired-AND’ed format that
allows arbitration in a multimaster system.
The transfer sequence of an I
2
C system consists of a master device initiating a transfer by generating 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 continues until the master
issues a stop condition and the bus becomes idle. Figure 19 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,
I2CxDIV (where x is 0 for I2C0 and 1 for I2C1). The master channel can be set to operate in fast mode (400 kHz) or standard mode (100 kHz).
MSB
START
BIT
SCL
ACK
BIT
ACK
BIT
STOP
BIT
SLAVE ADDRESS
SDA
MSB
LSB
LSB
DATA
1
1
7
8
8
9
9
2
3 TO 6
2 TO 7
R/W
1
1
176
-022
Figure 19. Typical I
2
C Transfer Sequence
The I
2
C bus peripheral address in the I
2
C bus system is programmed by the user. 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.
Configure the I
2
C clock in CLKCON1[10:8], CLKCON5[4] for I
2
C1, and CLKCON5[3] for I
2
C0.
2.
Configure digital pins (P0.4/P0.5, P0.6/P0.7) for I
2
C operation via the GP0CON register.
3.
Configure I
2
C registers as required for slave or master operation.
4.
Enable the I
2
C slave or master interrupt source as required.
Note that the user should disable the internal pull-up resistors on the I
2
C pins via the GP0PUL register when using I
2
C.
Table 134. GPIO Multiplex
GPIO
Configuration Mode (01)
P0.4, P0.6
SCL
P0.5, P0.7
SDA