UM10208_2
© NXP B.V. 2007. All rights reserved.
User manual
Rev. 02 — 1 June 2007
205 of 362
NXP Semiconductors
UM10208
Chapter 16: LPC2800 I
2
C
Assuming that the ISR reloaded the Tx FIFO for the Master Receive operation when
arbitration was lost, it can use this fact to differentiate these two cases. It should read the
number of bytes in the Tx FIFO from the I2TFL register and compare this value to the
variable that it saved when it loaded up the Tx FIFO. If the I2TFL value is equal to the
value of the variable, this is the “addressed as a slave” case, and the ISR should proceed
as described in
If the I2TFL value is less than the value of the saved variable, this is the “master retry”
case. The ISR should simply disable the Receive FIFO Not Empty interrupt in I2CTL, and
dismiss the interrupt.
If arbitration is not lost but no slave acknowledges the address, an interrupt will occur with
NAI in I2STS set. On seeing NAI=1, the ISR should write a SoftReset to I2CTL to purge
the Tx FIFO. It probably doesn’t want to retry the same Master Receive operation
immediately, as that would probably produce the same result. It can initiate another
Master Transmit or Master Receive operation. Otherwise, it should set the central state
variable to "idle", write I2CTL with RFNEE if another master can address the LPC288x as
a slave, or 0 if not, and then dismiss the interrupt.
Otherwise this must be an Operation Complete or Master Data Request interrupt. The ISR
should read the I2RX register and store the data bytes received from the slave, until RFE
in I2STS is 1. At this point it should check the OCI bit in I2STS to determine how to
proceed. If OCI is 0, the current receive frame is not complete, and the ISR should write
I2TX to control Start and Stop condition generation for future received bytes, and then
dismiss the interrupt.
In Master Receive mode the I
2
C interface acknowledges each byte it receives, except
bytes preceding a Start or Stop condition.
If OCI is 1, the Master Receive operation is complete. The ISR can initiate another Master
Transmit or Master Receive operation. Otherwise it should set the central state variable to
“idle”, write I2CTL with RFNEE if another master can address the LPC288x as a slave, or
0 if not, and dismiss the interrupt.
8.5 Slave mode
In any installation in which another master can access the LPC288x as a slave, the
RFNEE bit in I2CTL should be set at all times other than active operation as described in
these sections. The I
2
C ISR should maintain a central “state” variable, which may not by
changed by mainline code. An I
2
C interrupt with RFE=0 in I2STS, RFNEE=1 in I2CTL,
and the state variable set to any state other than “slave receive”, should lead the ISR to do
the following:
1. read an address/direction byte from I2RX,
2. optionally examine and/or save the address field,
3. save the value of the central state variable,
4. save the value of the I2CTL register,
5. proceed as described in
if the direction bit is 1,