2024-03-28 03:29 AM
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?
Solved! Go to Solution.
2024-03-28 06:30 AM
Hello @uhl ,
You can use the I2C configuration tool STSW-STM32126.
Please check these threads:
2024-03-28 06:30 AM
Hello @uhl ,
You can use the I2C configuration tool STSW-STM32126.
Please check these threads:
2024-06-05 07:38 AM
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