Standard, Fast, and Fast Plus modes are selected using a value in
the I2C Controller Timer Period (I2CMTPR) register that results in a maximum SCL frequency of:
- 100kbps for Standard mode
- 400kbps for Fast mode
- 1Mbps for Fast mode Plus
The I2C frequency I2C_FREQ is determined by the I2C_CLK frequency and bit fields TPR , SCL_LP , and SCL_HP where:
- I2C_CLK is the functional clock frequency to the
I2C module. Note that the I2C internal functional clock is first divided from the
source clock:
- Use I2Cx.CLKSEL register to select the source of the
I2C functional clock
- BUSSCLK: the current bus clock is selected as the
source for I2C. The current bus clock depends on power domain. If the I2C
instance is in power domain 1 (PD1) refer to MCLK, if the I2C instance is in power domain 0 (PD0) refer to ULPCLK.
- MFCLK: MFCLK is selected as the source for
I2C, refer to MFCLK.
- Use I2Cx.CLKDIV register to select divide ratio of
I2C function clock, options are from divide by 1 to 8.
- SCL_LP is the low phase of SCL (which must be fixed at
6)
- SCL_HP is the high phase of SCL (which must be fixed at
4)
- TPR is the programmed value of the TPR bits in the I2Cx.MTPR
register. This value is determined by replacing the known variables in the equation below and solving for
TPR
The I2C frequency is calculated as follows:
Equation 11. I2C_FREQ = I2C_CLK / ((1+TPR) × (SCL_LP + SCL_HP ))
For example, if the I2C functional clock frequency is
32MHz and target SCL frequency is 400kHz:
I2C_CLK = 32MHz
I2C_FREQ = 400kHz
SCL_LP = 6 , SCL_HP = 4
TPR = (I2C_CLK / (I2C_FREQ * (4 + 6))) - 1
TPR = 7 (0x07)
Table 13-1 Examples of Controller Clock Setting for Typical Clock
Configurations
Functional Clock |
TPR Bits Standard Mode 100kHz SCL |
TPR Bits Fast Mode 400kHz SCL |
TPR Bits Fast Mode Plus 1000kHz SCL |
4MHz |
0x03 |
- |
- |
8MHz |
0x07 |
0x01 |
- |
20MHz |
0x13 |
0x04 |
0x01 |
32MHz |
0x1F |
0x07 |
0x02(1) |
40MHz |
0x27 |
0x09 |
0x03 |
(1) With 32MHz functional clock, TPR = 0x01 generates 1.6MHz SCL frequency, and TPR = 0x02
generates 1.067MHz SCL frequency.
I2C functional clock must be greater than or equal to
20 times the SCL frequency, I2C_CLK ≥ 20 × I2C_FREQ.
The following minimum functional clock frequencies are required
when running certain I2C clock speeds:
- I2C_CLK ≥ 2MHz when working with I2C speed 0 to
100kHz
- I2C_CLK ≥ 8MHz when working with I2C speed 100 to
400kHz
- I2C_CLK ≥ 20MHz when working with I2C speed 400
kHz to 1MHz