
UM10850
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2016. All rights reserved.
User manual
Rev. 2.4 — 13 September 2016
307 of 464
NXP Semiconductors
UM10850
Chapter 23: LPC5410x I2C-bus interfaces (I2C0/1/2)
23.4.2.2 Slave write to master
•
Set the SLVEN bit to 1 in the CFG register. See
•
Write the slave address x to the address 0 match register. See
Write data to the master:
1. Wait for the pending status to be set (SLVPENDING = 1) by polling the STAT register.
2. ACK the address by setting SLVCONTINUE = 1 in the slave control register. See
3. Wait for the pending status to be set (SLVPENDING = 1) by polling the STAT register.
4. Write 8 bits of data to SLVDAT register. See
5. Continue the transaction by setting SLVCONTINUE = 1 in the slave control register.
See
23.4.3 Configure the I
2
C for wake-up
In sleep mode, any activity on the I
2
C-bus that triggers an I
2
C interrupt can wake up the
part, provided that the interrupt is enabled in the INTENSET register and the NVIC. As
long as the I
2
C clock I2C_PCLK remains active in sleep mode, the I
2
C can wake up the
part independently of whether the I
2
C block is configured in master or slave mode.
In Deep-sleep or Power-down mode, the I
2
C clock is turned off as are all peripheral
clocks. However, if the I
2
C is configured in slave mode and an external master on the
I
2
C-bus provides the clock signal, the I
2
C block can create an interrupt asynchronously.
This interrupt, if enabled in the NVIC and in the I
2
C block’s INTENCLR register, can then
wake up the core.
23.4.3.1 Wake-up from Sleep mode
•
Enable the I
2
C interrupt in the NVIC.
•
Enable the I
2
C wake-up event in the I2C INTENSET register. Wake-up on any
enabled interrupts is supported (see the INTENSET register). Examples are the
following events:
–
Master pending
–
Change to idle state
Table 338. Code example
Slave write to master
//Slave write 1 byte to master. Address 0x23, Data 0xdd. Polling mode.
I2C->SLVADR0 = 0x23 << 1; // put address in address 0 register
I2C->CFG = I2C_CFG_SLVEN;
I2C->CFG;
while(!(I2C->STAT & I2C_STAT_SLVPENDING));
if((I2C->STAT & I2C_STAT_SLVSTATE) != I2C_STAT_SLVST_ADDR) abort();
I2C->SLVCTL = I2C_SLVCTL_SLVCONTINUE; // ack address
while(!(I2C->STAT & I2C_STAT_SLVPENDING));
if((I2C->STAT & I2C_STAT_SLVSTATE) != I2C_STAT_SLVST_TX) abort();
I2C->SLVDAT = 0xdd; // write data
I2C->SLVCTL = I2C_SLVCTL_SLVCONTINUE; // continue transaction