cancel
Showing results for 
Search instead for 
Did you mean: 

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

budde2
Associate II
Posted on March 11, 2009 at 20:03

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

4 REPLIES 4
budde2
Associate II
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.

domen2
Associate III
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.

budde2
Associate II
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.

design5
Associate II
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.