![ARTERY AT32WB415 Series Скачать руководство пользователя страница 118](http://html1.mh-extra.com/html/artery/at32wb415-series/at32wb415-series_reference-manual_2977599118.webp)
AT32WB415
Series Reference Manual
2022.04.13
Page 118
Ver 2.00
is set 1 by hardware.
4. EV2: When the data is written to DT register, it is directly moved to the shift register, and SCL bus
is released. The TDBE is still set 1 at this time.
5. EV3: At this point, the DT register is empty but the shift register is not. Writing to the DT register
will clear the TDBE bit.
6. EV4: After receiving the ACKFAIL event from the master, ACKFIAL=1. Writing 0 to the ACKFIAL
bit will clear the event.
7. End of communication.
Slave receiver
Figure 11-4 shows the transfer sequence of slave receiver.
Figure 11-4 Transfer sequence of slave receiver
Address
S
A
Data1
A
SCL
Stretch
Data2
A
DataN
A
P
Master to Slave
Slave to Master
S = Start
A = Acknowledge
P = Stop
Example : I2C Slave receive N bytes from I2C Master .
EV1. I2C_STS1_ADDR7F = 1, Reading STS1 and then STS2 will clear the
event.
EV2. I2C_STS1_RDBF = 1
,
Reading the I2C_DT register will clear it.
EV3. When a stop condition is detected, I2C_STS1_STOPF = 1, reading STS1
and then writing CTRL1 register will clear the event
EV1
EV2
EV3
...
RDBF
Address Head
S
A
Address
A
SCL Stretch
Data1
A
Data2
A
DataN
A
P
EV2
EV3
...
EV1
7-bit address
10-bit address
EV2
EV2
EV2
EV2
0
R/W
0
R/W
11.4.2 I
2
C master communication flow
Master mode Initialization
1.
Porgram input clock to generate correct timing through the CLKFREQ bit in the I2C_CTRL2
register;
2.
Program I
2
C communication speed through the I2C_CLKCTRL bit in the clock control register;
3.
Program the maximum rising time of bus through the I2C_TMRISE register;
4.
Program the control register1
I2C_CTRL1;
5.
Enable peripherals, if the GENSTART bit is set, a Start condition is generated on the bus, and
the device enters master mode.
Slave address transmission
Slave address is divided into 7-bit and 10-bit modes. Whether it is transmitter mode or receiver mode
depends on the lowest address bit.
7-bit address mode:
Transmitter: When the lowest bit of the address sent is 0, the master enters transmitter mode.
Receiver: When the lowest bit of the address sent is 1, the master enters receiver mode.
10-bit address mode:
Transmitter: First send address head 0b11110xx0 (where xx refers to address [9: 8]), and then slave
address [7: 0], the master enters transmitter mode.