Skip to main content
FirmwareDev
Associate
December 7, 2018
Question

How can I calculate the I2C_TIMINGR value for STM32L496. I 'll be running I2C system clk with 80 MHz, what are timing register values or psc, scldel, sdadel, sclh, scll values at baud rate of 10 KHz, 100 KHz, 400 KHz, 500 KHz and 1 MHz?

  • December 7, 2018
  • 2 replies
  • 1832 views

..

    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    December 7, 2018

    I guess if CubeMX can't compute them for you, then you'd need to read the RM definitions and write a simple fitter algorithm to come up with workable numbers.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    FirmwareDev
    Associate
    December 7, 2018

    But how to get the values even in CubeMX tool as I am new in using CubeMX. I have set the clock as 80 MHz in MSI in CubeMX with correct MCU and set the values of PLLM, N and R values in code as well. But where to get the Timing Register values for I2C in cubeMX tool?

    Tesla DeLorean
    Guru
    December 7, 2018

    Not using CubeMX here, but I'd imagine the clock speed would be a drop down or menu item related to the configuration of the I2C interface/peripheral, and based on the system clocking you'd defined earlier.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    waclawek.jan
    Super User
    December 7, 2018

    As Clive wrote, if CubeMX does not calculate it for you, you read the register description in Reference Manual, draw a chart with the SDA and SCL signals and draw the timings between them, and calculate the required values for the individual fields, taking into account the requirements of the I2C specification.

    There are examples given for various I2C input clock frequencies and required bus clock frequencies, it's not that hard to derive from them.

    JW