Skip to main content
Explorer II
March 28, 2024
Solved

I2C Timing configuration for STM32G4xx

  • March 28, 2024
  • 1 reply
  • 1893 views

Hello guys,

I am having problems setting the correct I2C clock on the STM32G4xx in Master Mode.

 

The example configuration from the data sheet for 400 kHz at 16 MHz f_I2CCLK generates 432 kHz (RM0440-Rev4: P1892 Table 381). I use the __LL_I2C_CONVERT_TIMINGS() function, to convert the values from Datasheet.

An unchanged example from the CubeIDE also generates an incorrect frequency on my Nucleoboard. (CubeIDE version 1.15.0)

By trial and error I have now managed to generate almost exactly 400 kHz. In the TIMINGR I write 0x00100716, analogfilter enabled and digitalfilter disabled. Unfortunately I cannot reproduce this number with the information in the data sheet. So I can't get through the code review.

I was able to find a configuration tool for other controllers, is there such a tool for the STM32G4xx?

Can someone please help me to calculate the I2C timing correctly and comprehensibly?

    This topic has been closed for replies.
    Best answer by Imen.D

    Hello @uhl ,

    You can use the I2C configuration tool STSW-STM32126.

    Please check these threads:

    1 reply

    Imen.DAnswer
    Technical Moderator
    March 28, 2024

    Hello @uhl ,

    You can use the I2C configuration tool STSW-STM32126.

    Please check these threads:

    ST Employee
    June 5, 2024

    Hello,

    Concerning timing calculation for I2C, it is preferable to use STM32CubeMx, as this tool management the timing calculation for all STM32.

    The calculation of Timing is automatically done through CubeMx, when user select the Input clock frequency of the I2C, and in addition fill the rising, falling and Bus clock frequency, the parameter Timing is filled by the internal tool calculation.

    Prefer this method, instead of old usage of xls file.
    Regards