
MS51
Dec. 17, 2019
Page
96
of 316
Rev 1.01
M
S51
SE
RIES
TE
CHNICA
L REF
ERE
N
CE MA
NU
A
L
I2CON
– I
2
C Control
Regiser
Address
Reset Value
I2CON
C0H, all pages, Bit addressable
0000_0000 b
7
6
5
4
3
2
1
0
-
I2CEN
STA
STO
SI
AA
-
I2CPX
-
R/W
R/W
R/W
R/W
R/W
-
R/W
Bit
Name
Description
6
I2CEN
I
2
C bus enable
0 = I
2
C bus Disabled.
1 = I
2
C bus Enabled.
Before enabling the I
2
C, I2C0_SCL and I2C0_SDA port latches should be set to logic 1.
5
STA
START flag
When STA is set, the I
2
C generates a START condition if the bus is free. If the bus is busy, the I
2
C
waits for a STOP condition and generates a START condition following.
If STA is set while the I
2
C is already in the master mode and one or more bytes have been
transmitted or received, the I
2
C generates a repeated START condition.
Note that STA can be set anytime even in a slave mode, but STA is not hardware automatically
cleared after START or repeated START condition has been detected. User should take care of it
by clearing STA manually.
4
STO
STOP flag
When STO is set if the I
2
C is in the master mode, a STOP condition is transmitted to the bus. STO
is automatically cleared by hardware once the STOP condition has been detected on the bus.
The STO flag setting is also used to recover the I
2
C device from the bus error state (I2STAT as
00H). In this case, no STOP condition is transmitted to the I
2
C bus.
If the STA and STO bits are both set and the device is original in the master mode, the I
2
C bus will
generate a STOP condition and immediately follow a START condition. If the device is in slave
mode, STA and STO simultaneous setting should be avoid from issuing illegal I
2
C frames.
3
SI
I
2
C interrupt flag
SI flag is set by hardware when one of 26 possible I
2
C status (besides F8H status) is entered. After
SI is set, the software should read I2STAT register to determine which step has been passed and
take actions for next step.
SI is cleared by software. Before the SI is cleared, the low period of I2C0_SCL line is stretched. The
transaction is suspended. It is useful for the slave device to deal with previous data bytes until ready
for receiving the next byte.
The serial transaction is suspended until SI is cleared by software. After SI is cleared, I
2
C bus will
continue to generate START or repeated START condition, STOP condition, 8-bit data, or so on
depending on the software configuration of controlling byte or bits. Therefore, user should take care
of it by preparing suitable setting of registers before SI is software cleared.
2
AA
Acknowledge assert flag
If the AA flag is set, an ACK (low level on I2C0_SDA) will be returned during the acknowledge clock
pulse of the I2C0_SCL line while the I
2
C device is a receiver or an own-address-matching slave.
If the AA flag is cleared, a NACK (high level on I2C0_SDA) will be returned during the acknowledge
clock pulse of the I2C0_SCL line while the I
2
C device is a receiver or an own-address-matching
slave. A device with its own AA flag cleared will ignore its own salve address and the General Call.
Consequently, SI will note be asserted and no interrupt is requested.
Note that if an addressed slave does not return an ACK under slave receiver mode or not receive
an ACK under slave transmitter mode, the slave device will become a not addressed slave. It
cannot receive any data until its AA flag is set and a master addresses it again.
There is a special case of I2STAT value C8H occurs under slave transmitter mode. Before the slave
device transmit the last data byte to the master, AA flag can be cleared as 0. Then after the last
data byte transmitted, the slave device will actively switch to not addressed slave mode of
disconnecting with the master. The further reading by the master will be all FFH.