
NuMicro® NUC029LEE/NUC029SEE
32-bit Arm
®
Cortex
®
-M0 Microcontroller
Aug, 2018
Page
394
of
497
Rev 1.00
N
U
MICRO
®
N
UC02
9L
E
E
/N
UC029
S
E
E
T
E
CHN
ICA
L R
E
F
E
R
E
NC
E
M
A
NU
A
L
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 6.14-8 Master Reads Data from Slave
6.14.5.2 Operation Modes
The on-chip I
2
C ports support three operation modes, Master, Slave, and General Call Mode.
In a given application, I
2
C port may operate as a master or as a slave. In Slave mode, the I
2
C port
hardware looks for its own slave address and the general call address. If one of these addresses
is detected, and if the slave is willing to receive or transmit data from/to master(by setting the AA
bit), acknowledge pulse will be transmitted out on the 9th clock, hence an interrupt is requested
on both master and slave devices if interrupt is enabled. When the microcontroller wishes to
become the bus master, hardware waits until the bus is free before entering Master mode so that
a possible slave action is not be interrupted. If bus arbitration is lost in Master mode, I
2
C port
switches to Slave mode immediately and can detect its own slave address in the same serial
transfer.
To control the I
2
C bus transfer in each mode, user needs to set I2CON, I2CDAT registers
according to current status code of I2CSTATUS register. In other words, for each I
2
C bus action,
user needs to check current status by I2CSTATUS register, and then set I2CON, I2CDAT
registers to take bus action. Finally, check the response status by I2CSTATUS.
The bits, STA(I2CON[5]), STO(I2CON[4]) and AA(I2CON[2]) are used to control the next state of
the I
2
C hardware after SI (I2CON[3]) flag is cleared. Upon completion of the new action, a new
status code will be updated in I2CSTATUS register and the SI flag will be set. If the I
2
C interrupt
control bit EI (I2CON [7]) is set, appropriate action or software branch of the new status code can
be performed in the Interrupt service routine.
The following figure shows the current I
2
C status code is 0x08, and then set I2CDATA=SLA+W
and (STA,STO,SI,AA) = (0,0,1,x) to send the address to I
2
C bus. If a slave on the bus matches
the address and response ACK, the I2CSTATUS will be updated by status code 0x18.
S
I2CDAT
(SLA+W)
ACK
Last Status
STATUS=0x08
Updated Status
STATUS=0x18
Register Control
I2CDAT=SLA+W
(STA,STO,SI,AA)=(0,0,1,x)
Master to Slave
Slave to Master
Figure 6.14-9 Control I
2
C Bus according to Current I
2
C Status