UM11029
All information provided in this document is subject to legal disclaimers.
© NXP Semiconductors N.V. 2017. All rights reserved.
User manual
Rev. 1.0 — 16 June 2017
332 of 515
NXP Semiconductors
UM11029
Chapter 19: LPC84x I2C0/1/2/3
19.3.1.1 Master write to slave
Configure the I2C as master: Set the MSTEN bit to 1 in the CFG register. See
.
Write data to the slave:
1. Write the slave address with the RW bit set to 0 to the Master data register MSTDAT.
See
2. Start the transmission by setting the MSTSTART bit to 1 in the Master control register.
See
. The following happens:
–
The pending status is cleared and the I2C-bus is busy.
–
The I2C master sends the start bit and address with the RW bit to the slave.
3. Wait for the pending status to be set (MSTPENDING = 1) by polling the STAT register.
4. Write 8 bits of data to the MSTDAT register.
5. Continue with the transmission of data by setting the MSTCONT bit to 1 in the Master
control register. See
. The following happens:
–
The pending status is cleared and the I2C-bus is busy.
–
The I2C master sends the data bits to the slave address.
6. Wait for the pending status to be set (MSTPENDING = 1) by polling the STAT register.
7. Stop the transmission by setting the MSTSTOP bit to 1 in the Master control register.
See
19.3.1.2 Master read from slave
Configure the I2C as master: Set the MSTEN bit to 1 in the CFG register. See
.
Read data from the slave:
1. Write the slave address with the RW bit set to 1 to the Master data register MSTDAT.
See
2. Start the transmission by setting the MSTSTART bit to 1 in the Master control register.
See
. The following happens:
–
The pending status is cleared and the I2C-bus is busy.
–
The I2C master sends the start bit and address with the RW bit to the slave.
–
The slave sends 8 bit of data.
3. Wait for the pending status to be set (MSTPENDING = 1) by polling the STAT register.
4. Read 8 bits of data from the MSTDAT register.
5. Stop the transmission by setting the MSTSTOP bit to 1 in the Master control register.
See
19.3.2 I2C receive/transmit in slave mode
In this example, the I2C is configured as the slave. The slave receives 8 bits from the
master and sends 8 bits to the slave. You must enable the I2C0_SCL and I2C0_SDA
functions on pins PIO0_11 and PIO0_10 or assign the SCL and SDA functions for any of
the other I2C blocks to pins through the switch matrix. See
.