UM10208_2
© NXP B.V. 2007. All rights reserved.
User manual
Rev. 02 — 1 June 2007
202 of 362
NXP Semiconductors
UM10208
Chapter 16: LPC2800 I
2
C
8.
Details of I
2
C operating modes
8.1 Initialization
In an application that uses the I
2
C interface, software should do the following between
Reset and when the I
2
C is used:
1. Write the I2CLKHI and I2CLKLO registers with values determined as described in
C data rate and duty cycle” on page 201.
2. If slave operation is needed, write the I2ADR register with the LPC288x’s slave
address.
3. Write the I2CTL register with RFNEE if another master can access the LPC288x as a
slave, or 0 if not, plus optionally a 1 in the SoftReset bit to ensure that the hardware is
in a good initial state.
8.2 Interrupt enabling
This description is written with the assumption that software will handle the I
2
C on an
interrupt-driven basis. Master transmission and reception can both be handled by
enabling the Operation Complete and No Acknowledge interrupts, plus the Master Data
Request interrupt if frames longer than 16 bytes are ever sent or received. If there’s
another master in the application, enable the Arbitration Failure interrupt.
For slave operation the Receive FIFO Not Empty interrupt should be enabled when a
master operation loses arbitration, and when no master operation is pending or in
progress, but RFNE should not be enabled for Master Reception.
The following procedures use a routine called “set_IEs” that mainline code can call to set
bits in the I2CTL register. It must
1. disable interrupts (at least the I
2
C interrupt),
2. read I2CTL,
3. OR the value from the caller with the previous I2CTL value,
4. write the result back to I2CTL, and
5. re-enable the interrupt(s) it disabled
Table 229. Example I
2
C clock rates
I
I2CLKLO
I
2
C bit frequency (kHz) at PCLK (MHz)
1
5
10
16
20
40
60
8
125
10
100
25
40
200
400
50
20
100
200
320
400
100
10
50
100
160
200
400
160
6.25
31.25
62.5
100
125
250
375
200
5
25
50
80
100
200
300
400
2.5
12.5
25
40
50
100
150
800
1.25
6.25
12.5
20
25
50
75