AT32F425
Series Reference Manual
2022.03.30
Page 120
Ver 2.01
―
Step 3: After the completion of 255-byte data transfer, the TCRLD is set in the I2C_STS register,
and then configure CNT[7:0]=255 for continuous transfer, the remaiming bytes are 345-255=90
―
Step 4: After the completion of the seond 255-byte data transfer, the TCRLD is set in the
I2C_STS register, and then set RLDEN=0 to disable reload mode before setting CNT[7:0]=90
for continuous transfer.
There are two ways to stop the last data transfer (RLDEN=0, reload mode is disabled)
Stop data transfer automatically ( ASTOPEN=1 in the I2C_CTRL2)
―
When the number of data programmed in the CNT[7:0] bit has been fully transferred, the master
will automatically send a STOP condition
Stop data transfer by software
(ASTOPEN=0 in the I2C_CTRL2)
―
When the number of data programmed in the CNT[7:0] has been fully transferred, the TDC will
be set in the I2C_STS register, and the SCL, at this point, will be pulled low, an interrupt
generated if TDCIEN is enabled. In this case, it is possible to send a STOP condition by setting
GENSTOP=1 in the I2C_CTRL2 register, or send a RESTART condition by setting
GENSTART=1 in the I2C_CTRL2 register, before clearing TDC flag by software.
Byte control through slave
This feature is enabled by setting the SCTRL bit in the I2C_CTRL2 register so that the slave is able to
control ACK/NACK signals of each byte independently.
Proceed as below:
―
S
et SCTRL=1 to enable Byte Control Through Slave
―
After the slave address is matched (ADDRF=1), enable reload mode by setting RLDEN=1, and
then set CNT[7:0]=1
―
When a byte is received, the TCRLD is set in the I2C_STS register, and the slave will pull the
SCL bus low between the 8th and 9th clock edges. At this point, the user can read the RXDT
register and generate an ACK or NACK signal through the NACKEN bit in the I2C_CTRL2
register
―
When an NACK signal is generated, it indicates the end of communication
―
When an ACK signal is generated, the communication flow keeps going on. At this point, set
CNT[7:0]=1, the TCRLD flag is cleared automatically by hardware, and the SCL bus is released
for the reception of the next byte
As we know, the value in the CNT[7:0] bit is not limited to 1. If you want to receive 8 data, for example,
but just want to control the ACK/NACK signals of the 8
th
data. Proceed as below: set CNT[7:0]=8, the
slave will receive 7 consecutive data, with ACK signals sent. Once the 8
th
data reception is completed,
the SCL bus is pulled low, and then proceed as above to select whether to send an ACK or NACK.
It should be noted that the clock stretching capability must be enabled (STRETCH=0 in the I2C_CTRL1
register) before selecting Byte Control Mode Through Slave.
Table 11-2 I
2
C configuration table
Description
RLDEN
ASTOPEN
SCTRL
Master transmit/receive RESTART
0
0
×
Master transmit/receive STOP
0
1
×
Slave receive (control ACK/NACK of each byte
)
1
×
1
Slave transmit/receive (ACK response to all bytes)
×
×
0
11.4.3 I
2
C master communication flow
1.
I
2
C
clock initialization (by setting the I2C_CLKCTRL register)
―
I
2
C
clock divider: DIV[7: 0]
―
Data hold time (t
H D ; D A T
):
SDAD[3: 0]
―
Data setup time (t
S U ; D AT
)
: SCLD[3: 0]
―
SCL high duration: SCLH[7: 0]