AT32WB415
Series Reference Manual
2022.04.13
Page 124
Ver 2.00
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). Clear the ACKEN bit, read STS1 and
then STS2 will clear the ADDR7F bit. Afterwards, set GENSTOP=1, the master enters
receive stage at this time.
4.
EV3: RDBF=1. It is cleared when the I2C_DT register is read.
5.
End of communication.
10-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.
EV5: 10-bit address head is sent. Read STS1 and write to DT register can clear the
ADDRHF bit.
4.
EV4: Address is matched successfully (ADDR7F=1). Read STS1 and STS2 will clear the
ADDR7F bit, the master re-sends Start condition (GENSTART=1).
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). Clear the ACKEN bit, read STS1 and
then STS2 will clear the ADDR7F bit. Afterwards, set GENSTOP=1, the master enters
receive stage at this time.
7.
EV3: RDBF=1. It is cleared when the I2C_DT register is read.
8.
End of communication.
11.4.3 Data transfer using DMA
I
2
C data transfer can be done using DMA controller. An interrupt is generated by enabling the transfer
complete interrupt bit. The DATAIEN bit in the I2C_CTRL2 register must be set 0 when using DMA for
data transfer. The following sequence is for data transfer with DMA.
Transmission using DMA
1.
Set the peripheral address (DMA_CxPADDR=
I2C_D
T address)
2.
Set the memory address (DMA_CxMADDR=data memory address)
3.
The transmission direction is set from memory to peripheral (DTD=1 in the DMA_CHCTRL
register)
4.
Configure the total number of bytes to be transferred in the DMA_CxDTCNT register
5.
Configure other parameters such as priority, memory data width, peripheral data width,
interrupts, etc in the DMA_CHCTRL register
6.
Enable the DMA channel by setting CHEN=1 in the DMA_CxCTRL register
7.
Enable I
2
C
DMA request by setting DMAEN=1 in the
I2C_CTRL2 register. Once the TDBE
bit in the
I2C_STS1 register is set, the data is loaded from the programmed memory to the
I2C_DT register through DMA
8.
When the number of data transfers, programmed in the DMA controller, is reached
(DMA_CxDTCNT=0), the data transfer is complete (An interrupt is generated if enabled).
9.
Master transmitter: Once the TDC flag is set, the STOP condition is generated, indicating that
transfer is complete.
Slave transmitter: Once the ACKFAIL flag is set, clear the ACKFAIL flag, transfer is complete.
Reception using DMA
1.
Set the peripheral address (DMA_CxPADDR =
I2C_DT address
)
2.
Set the memory address (DMA_CxMADDR = memory address)
3.
The transmission directionis set from peripheral to memory (DTD=0 in the DMA_CHCTRL
register)
4.
Configure the total number of bytes to be transferred in the DMA_CxDTCNT register