UM10237_2 © NXP B.V. 2008. All rights reserved.
User manual Rev. 02 — 19 December 2008 603 o f 792
NXP Semiconductors UM10237
Chapter 22: LPC24XX I2C interfaces I2C0/1/2
The I2C hardware now begins checking the I2C bus for its own slave address and general
call. If the general call or the own slave address is detected, an interrupt is requested and
I2STAT is loaded with the appropriate state information.

9.12.2 I2C interrupt service

When the I2C interrupt is entered, I2STAT contains a status code which identifies one of
the 26 state services to be executed.

9.12.3 The state service routines

Each state routine is part of the I2C interrupt routine and handles one of the 26 states.

9.12.4 Adapting state services to an application

The state service examples show the typical actions that must be performed in response
to the 26 I2C state codes. If one or more of the four I2C operating modes are not used, the
associated state services can be omitted, as long as care is taken that the those states
can never occur.
In an application, it may be desirable to implement some kind of timeout during I2C
operations, in order to trap an inoperative bus or a lost service routine.
10. Software example

10.1 Initialization routine

Example to initialize I2C Interface as a Slave and/or Master.
1. Load I2ADR with own Slave Address, enable general call recognition if needed.
2. Enable I2C interrupt.
3. Write 0x44 to I2CONSET to set the I2EN and AA bits, enabling Slave functions. For
Master only functions, write 0x40 to I2CONSET.

10.2 Start master transmit function

Begin a Master Transmit operation by setting up the buffer, pointer, and data count, then
initiating a Start.
1. Initialize Master data counter.
2. Set up the Slave Address to which data will be transmitted, and add the Write bit.
3. Write 0x20 to I2CONSET to set the STA bit.
4. Set up data to be transmitted in Master Transmit buffer.
5. Initialize the Master data counter to match the length of the message being sent.
6. Exit

10.3 Start master receive function

Begin a Master Receive operation by setting up the buffer, pointer, and data count, then
initiating a Start.
1. Initialize Master data counter.