AT32F421
Series Reference Manual
2022.11.11
Page 118
Rev 2.02
10. End of communication.
3.
When I
2
C interrupt priority is not very high but the number of bytes to receive is equal to 2
Set the MACKCTRL bit in the I2C_CTRL1 register before data reception. When the address is
matched, clear ACKEN bit and then the ADDR7F bit. When the TDC bit is set 1, set the
GENSTOP bit in the I2C_CTRL1 register, and then read the DT register.
Figure 11-8 Transfer sequence of master receiver when N=2
Address
S
1
A
Data1
NA
SCL
Stretch
P
Master to Slave
Slave to Master
RS = Repeated Start
S = Start
A = Acknowledge
P = Stop
Example : I2C Master receive 1 bytes from I2C Slave .
EV1. I2C_STS1_STARTF=1, reading STS1 and write the address to
I2C_DT will clear the event.
EV2. I2C_STS1_ADDR7F = 1, clear the I2C_CTRL1_ACKEN bit, and
reading STS1 and then STS2 will clear the event, then set the
I2C_CTRL1_GENSTOP bit = 1.
EV3. I2C_STS1_RDBF =1,reading the I2C_DT register will clear the
event.
EV4. I2C_STS1_ADDR7F = 1, reading STS1 and then STS2 will
clear the event.
EV5. I2C_STS1_ADDRHF= 1, reading STS1 and write I2C_DT
register will clear the event.
EV2
EV3
RDBF
Address Head
S
A
SCL
Stretch
Address
A
EV4
EV5
10-bit address
Address Head
RS
SCL Stretch
A
Data1
NA
SCL Stretch
P
EV2
EV3
7-bit address
R/W
0
R/W
1
R/W
SCL
Stretch
EV1
SCL
Stretch
EV1
SCL Stretch
EV1
7-bit address mode:
1.
Set MACKCTRL=1 in the I2C_CTRL1 register
2.
Generate Start condition (GENSTART=1)
3.
EV1: Start condition is ready (STARTF=1). Read STS1 and write the address to DT register.
4.
EV2: Address is matched successfully (ADDR7F=1). Clear the ACKEN bit and read STS1
and STS2 clears the ADDR7F bit, the master enters receive state at this time.
5.
EV2: TDC=1, set GENSTOP=1, and then read the I2C_DT register twice.
6.
End of communication.
10-bit address mode:
1.
Set MACKCTRL=1 in the I2C_CTRL1 register
2.
Generate Start condition (GENSTART=1)
3.
EV1: Start condition is ready (STARTF=1). Read STS1 and write the address to DT register.
4.
EV4: 10-bit address head is sent. Reading STS1 and writing to DT register can clear the
ADDRHF bit.
5.
EV2: Address is matched successfully (ADDR7F=1). Reading STS1 and then STS2 clears
the ADDR7F bit, and the master re-send Start condition.
6.
EV1: Start condition is ready (STARTF=1). Read STS1 and write the address to the DT
register.
7.
EV2: Address is matched successfully (ADDR7F=1). Clear the ACKEN bit and read STS1
and STS2 clears the ADDR7F bit, the master enters receive state at this time.
8.
EV3: TDC=1, set GENSTOP=1, and then read the I2C_DT register twice.