
NUC126
Aug. 08, 2018
Page
834
of 943
Rev 1.03
NUC12
6 S
E
RI
E
S
T
E
CH
NI
CA
L R
E
F
E
RE
NCE
MA
NUA
L
7. Set ACKIEN, ERRIEN, ARBLOIEN, NACKIEN, STORIEN, STARIEN, and TOIEN to enable
I
2
C Interrupt in the “UI2C_PROTIEN” register.
8.
Set USCI address registers “USCI_ADDR0 ~ USCI_ADDR1”.
Random read operation is one of the methods of access EEPROM. The method allows the master to
access any address of EEPROM space. Figure 6.22-21 shows the EEPROM random read operation.
S
T
A
1 0 1 0
A
2
A
1
A
0
W
A
C
K
X X X
A
C
K
A
C
K
S
T
1 0 1 0
A
2
A
1
A
0
R
A
C
K
N
A
C
K
S
T
O
DATA BYTE
ROM ADDRRSS
LOW BYTE
ROM ADDRRSS
HIGH BYTE
SLA+W
SDA
LINE
SLA+R
Figure 6.22-20 EEPROM Random Read
Figure 6.22-21 shows how to use I
2
C controller to implement the protocol of EEPROM random read.
S
TXDAT
(SLA+W)
ACK
Master to Slave
Slave to Master
TXDAT
(
ROM Address High Byte
)
ACK
Sr
TXDAT
(SLA+R)
ACK
P
STARIF = 1
(PTRG, STA, STO, AA) = (0, 1, 0, x)
Clear protocol status register
ACKIF = 1
TXDAT = SLA+W
(PTRG, STA, STO, AA)=(1, 0, 0, x)
Write 1 to STARIF
ACKIF = 1
TXDAT = Data
((PTRG, STA, STO, AA)=(1, 0, 0, x)
Writing 1 to ACKIF
STARIF = 1
(PTRG, STA, STO, AA)=(1, 1, 0, x)
Clear protocol status register
STORIF = 1
(PTRG, STA, STO, AA)=(1, 0, 1, x)
Writing 1 to NACKIF
TXDAT = SLA+W
(PTRG, STA, STO, AA)=(1, 0, 0, x)
Write 1 to STARIF
ACKIF = 1
NAK
NACKIF = 1
TXDAT
(
ROM Address Low Byte
)
ACK
ACKIF = 1
I2C_DAT=ROM Address Low Byte
(PTRG, STA, STO, AA)=(1, 0, 0, x)
P
STORIF = 1
(PTRG, STA, STO, AA)=(1, 0, 1, x)
Writing 1 to NACKIF
NAK
NACKIF = 1
TXDAT
(Data)
NAK
NACKIF = 1
Read I2C_DAT to Get Data
(PTRG, STA, STO, AA)=(1, 0, 0, 0)
Writing 1 to ACKIF
P
STORIF = 1
(PTRG, STA, STO, AA)=
(1, 0, 1, x)
Writing 1 to NACKIF
NAK
NACKIF = 1
P
STORIF = 1
(PTRG, STA, STO, AA)=(1, 0, 1, x)
Writing 1 to NACKIF
Figure 6.22-21 Protocol of EEPROM Random Read
The I
2
C controller, which is a master, sends START to bus. Then, it sends a SLA+W (Slave a
Write bit) to EERPOM followed by two bytes data address to set the EEPROM address to read.
Finally, a Repeat START followed by SLA+R is sent to read the data from EEPROM.