AT32F425
Series Reference Manual
2022.03.30
Page 121
Ver 2.01
―
SCL low duration: SCLL[7: 0]
2.
Set the number of bytes to be transferred
― ≤
255 bytes
Disable reload mode by setting RLDEN=0 in the I2C_CTRL2 register
Set CNT[7:0]=N in the I2C_CTRL2 register
― >
255 bytes
Enable reload mode by setting RLDEN=1 in the I2C_CTRL register
Set CNT[7:0]=255 in the I2C_CTRL2 register
Remaining bytes N=N-255
3.
End of data transfer
―
ASTOPEN=0: stop data transfer by software. After the completion of data transfer, the TDC is
set in the I2C_STS register, and GENSTOP=1 or GENSTART=1 is written by software to send
a STOP or START condition
―
ASTOPEN=1: data transfer is stopped automatically. A STOP condition is sent at the end of
data transfer
4.
Set slave address
―
Set slave address value (by setting the SADDR bit in the I2C_CTRL2 register)
―
Set slave address mode (by setting the ADDR10 bit in the I2C_CTRL2 register)
ADDR10=0: 7-bit address mode
ADDR10=1: 10-bit address mode
5.
Set transfer direction (by setting the DIR bit in the I2C_CTRL2 register)
―
DIR=0: Master reception
―
DIR=1: Master transmission
6.
Start data transfer
When GENSTART=1 in the I2C_CTRL2 register, the master starts sending a START condition and
slave address. After receiving the ACK from the slave, ADDRF=1 is asserted in the I2C_STS
register. The ADDRF flag can be cleared by setting ADDRC=1 in the I2C_CLR register, and then
data transfer starts.
7.
Master transmit
1.
I2C_TXDT data register is empty, the shift register is empty, TDIS=1 in the I2C_STS register
2.
Writing 1 to the TXDT register, and data is immediately moved to the shift register
3.
TXDT register becomes empty, TDIS=1 again
4.
Writing 2 to the TXDT register, TDIS is cleared
5.
Repeat step 2 and 3 until the data in the CNT[7:0] is sent
6.
If TCRLD=1 (reload mode) in the I2C_STS register, the following two circumstances
should be noted:
Remaining bytes N>255: write 255 to the CNT bit, N=N-255, TCRLD is cleared, and data
transfer continues
Remaining bytes N≤255: Disable reload mode (RLDEN=0), write N to the CTN bit, TCRLD
is cleared, and data transfer continues
8.
Master receive
1.
After the slave address is matched, ADDRF=1 in the I2C_STS register, clear ADDRF flag by
setting ADDRC=1 in the I2C_CLR register, and then it starts sending data
2.
After the reception of data, RDBF=1, read the RXDT register will clear the RDBF automatically
3.
Repeat step 2 until the reception of data programmed in the CNT[7:0] bit
4.
If TCRLD=1 (reload mode) in the I2C_STS, the following two circumstances should be noted:
Remaining bytes N>255: write 255 to the CNT bit, N=N-255, TCRLD is cleared, and data
transfer continues
Remaining bytes N≤255: Disable reload mode (RLDEN=0), write N to the CTN bit, TCRLD
is cleared, and data transfer continues
5.
After the reception of the last data, an NACK signal will be sent by master
9.
STOP condition
―
STOP condition generation:
ASTOPEN=0: TDC=1 in the I2C_STS register, set GENSTOP=1 to generate a STOP condition
ASTOPEN=1: A STOP condition is generated automatically