Skip to main content
budde2
Associate III
March 11, 2009
Question

[Bug STM32 Lib] I2C clock wrong (> 100 kHz)

  • March 11, 2009
  • 4 replies
  • 938 views
Posted on March 11, 2009 at 20:03

[Bug STM32 Lib] I2C clock wrong (> 100 kHz)

    This topic has been closed for replies.

    4 replies

    budde2
    budde2Author
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:05

    Hi,

    I have problems with the SCL clock generated by the I2C core, if I configure a clock speed > 100 kHz.

    If I set e.g. 400 kHz in I2C_Init(), I get something around 630 kHz. My PCLK1 is 36 MHz.

    I think the following line in the firmware library is wrong:

    result = (u16)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 3));

    After changing it to

    result = (u16)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 2));

    everything works as expected.

    I think the same error is in the reference manual.

    budde2
    budde2Author
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:05

    I am using the STM3210-E board (RCC_GetClocksFreq() reports PCLK1 36 MHz) and or own board with a 16 MHz external clock.

    I think everything is configured right.

    domen2
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 13:05

    Or maybe Fwlib was compiled with wrong HSE_Value? (ie. 8mhz, but you have 12mhz crystal)

    Well... in this case you should see similar symptoms for other devices, like uart.

    design5
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:05

    Budde:

    Without testing it myself, I think your analysis is correct. I have found several bugs in the Firmware Library and in the Documentation (both Hardware Manual and Firmware Library documents). I expect there are many more minor bugs such as this one.

    So, thanks for finding this bug. I have changed my firmware library accordingly.

    Garry.