Inter-integrated circuit (I2C) interface UM0306
334/519
15.4.2 I
2
C master mode
In Master mode, the I
2
C interface initiates a data transfer and generates the clock signal. A
serial data transfer always begins with a Start condition and ends with a Stop condition.
Master mode is selected as soon as the Start condition is generated on the bus with a
START bit.
The following is the required sequence in master mode.
● Program the peripheral input clock in I2C_CR2 Register in order to generate correct
timings
● Configure the clock control registers
● Configure the rise time register
● Program the I2C_CR1 register to enable the peripheral
● Set the START bit in the I2C_CR2 register to generate a Start condition
The peripheral input clock frequency must be at least:
● 2 MHz in Standard mode
● 4 MHz in Fast mode
Start condition
Setting the START bit while the BUSY bit is cleared causes the interface to generate a Start
condition and switch to Master mode (M/SL bit set).
Once the Start condition is sent:
● The SB bit is set by hardware and an interrupt is generated if the ITEVFEN bit is set.
Then the master waits for a read of the SR1 register followed by a write in the DR register
with the Slave address (see Figure 137 & Figure 138 Transfer sequencing EV5).
Slave address transmission
Then the slave address is sent to the SDA line via the internal shift register.
● In 10-bit addressing mode, sending the header sequence causes the following event:
– The ADD10 bit is set by hardware and an interrupt is generated if the ITEVFEN bit
is set.
Then the master waits for a read of the SR1 register followed by a write in the DR
register with the second address byte (see Figure 137 & Figure 138 Transfer
sequencing).
– The ADDR bit is set by hardware and an interrupt is generated if the ITEVFEN bit
is set.
Then the master waits for a read of the SR1 register followed by a read of the SR2
register (see Figure 137 & Figure 138 Transfer sequencing).
● In 7-bit addressing mode, one address byte is sent.
As soon as the address byte is sent,
– The ADDR bit is set by hardware and an interrupt is generated if the ITEVFEN bit
is set.
Then the master waits for a read of the SR1 register followed by a read of the SR2
register (see Figure 137 & Figure 138 Transfer sequencing).