AT32F421
Series Reference Manual
2022.11.11
Page 117
Rev 2.02
the GENSTOP bit in the I2C_CTRL1 register and read the second-to-last byte (N-1). The bus
then starts to receive the last one byte.
Figure 11-7 Transfer sequence of master receiver when N>2
Address
S
1
A
Data1
A
SCL
Stretch
Data2
A
DataN
NA P
Master to Slave
Slave to Master
RS = Repeated Start
S = Start
A = Acknowledge
P = Stop
Example : I2C Master receive N 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, reading STS1 and then STS2 will clear the event.
EV3. I2C_STS1_RDBF = 1
,
read the I2C_DT register to clear the event.
EV4. I2C_STS1_TDC = 1
,
The I2C_DT register data is DataN-2, the internal shift register data is DataN-1, set
I2C_CTRL1_ACKEN = 0, after the software reads the data DataN-2, set I2C_CTRL1_GENSTOP = 1, and
then read the data DataN-1.
EV5. I2C_STS1_ADDRHF= 1 ,reading STS1 and write I2C_DT register will clear the event.
EV2
EV3
EV4
...
RDBF
DataN-2
A
DataN-1
A
SCL
Stretch
Address Head
S
A
SCL
Stretch
Address
A
EV2
EV5
10-bit address
Address Head
RS
SCL
Stretch
A
Data1
A
Data2
A
DataN
NA P
EV3
EV4
...
DataN-2
A
DataN-1
A
SCL
Stretch
EV3
EV3
EV3
EV3
7-bit address
R/W
0
R/W
1
R/W
SCL
Stretch
EV1
SCL
Stretch
EV1
EV2
SCL
Stretch
EV1
SCL Stretch
7-bit address mode:
1.
Generate a Start condition (GENSTART=1)
2.
EV1: Start condition is ready (STARTF=1). Read STS1 and write the address to DT register.
3.
EV2: Address is matched successfully (ADDR7F=1). Reading STS1 and then STS2 clears
the ADDR7F bit, and the master enters receive stage.
4.
EV3: The RDBF bit is set 1 after receiving the byte. Reading the I2C_DT register clears the
RDBF.
5.
EV4: TDC=1, the contents in the I2C_DT is N-2, and that of the shift register is N-1. The
ACKEN is set 0 by software and the data N-2 is read, afterwards, the GENSTOP=1, and data
N-1 is read.
6.
EV3: The RDBF bit is set 1 after receiving the byte. Reading the I2C_DT register clears the
RDBF.
7.
End of communication.
10-bit address mode:
1.
Generate Start condition (GENSTART=1)
2.
EV1: Start condition is ready (STARTF=1). Read STS1 and write the address to DT register.
3.
EV5: 10-bit address head sequence is sent. Reading STS1 and writing to DT register can
clear the ADDRHF bit.
4.
EV2: Address is matched successfully (ADDR7F=1). Reading STS1 and then STS2 clears
the ADDR7F bit, and the master re-send Start condition.
5.
EV1: Start condition is ready (STARTF=1). Read STS1 and write the address to the DT
register.
6.
EV2: Address is matched successfully (ADDR7F=1). Reading STS1 and then STS2 clears
the ADDR7F bit, and the master enters receive stage.
7.
EV3: The RDBF bit is set 1 after receiving a byte. Reading the I2C_DT register clears the
RDBF.
8.
EV4: TDC=1, the contents in the I2C_DT is N-2, and that of the shift register is N-1. The
ACKEN is set 0 by software and the data N-2 is read, afterwards, the GENSTOP=1, and data
N-1 is read.
9.
EV3: The RDBF bit is set 1 after receiving a byte. Reading the I2C_DT register clears the
RDBF.