
NUC970 Technical Reference Manual
Publication Release Date: Dec. 15, 2015
- 522 -
Revision V1.30
NUC97
0
T
E
CHNIC
A
L
RE
F
E
RE
N
CE
MA
NUA
L
The following figure shows a master read data from slave. A master addresses a slave with a 7-
bit address and 1-bit read index to denote that the master wants to read data from the slave. The
slave will start transmitting data after the slave returns acknowledge to the master.
‘1’ : read
S
SLAVE ADDRESS
R/W
A
DATA
A
DATA
A/A
P
data transfer
(n bytes + acknowlegde)
Figure 5.18-8 Master Reads Data from Slave
For the data transmission, the I
2
C core used 32-bit transmit buffer and provide multi-byte transmit
function. Set CSR[Tx_NUM] to a value that you want to transmit. I
2
C core will always issue a
transfer from the highest byte first. For example, if CSR[Tx_NUM] = 0x3, Tx[31:24] will be
transmitted first, then Tx[23:16], and so on.
In case of a data transfer, all bits will be treated as data.
In case of a slave address transfer, the first 7 bits will be treated as 7-bit address and the LSB
represent the R/W bit. In this case, LSB = 1, reading from slave and LSB = 0, writing to slave.
I2C Programming Examples
5.18.5.7
Example 1
Write 1 byte of data to a slave (using multi-byte transmit mode).
Slave address = 0x51 (7b’1010001)
Data to write = 0xAC
I
2
C Sequence:
generate start command
write slave a write bit
receive acknowledge from slave
write data
receive acknowledge from slave
generate stop command
Commands:
Write a value into DIVIDER to determine the frequency of serial clock.
Set Tx_NUM = 0x1 and set I2C_EN = 1 to enable I
2
C core.
Write 0xA2 (a write bit) to Transmit Register (TxR[15:8]) and 0xAC to TxR[7:0].
Set START bit and WRITE bit.