2017-06-15 01:25 PM
I am using the stm32l1xx_i2c.c code and I am successfully using I2C to interface with a BNO055 IMU. Everything is working perfectly at 100 kHz and now I want to speed that up as much as I can. My PCLK1 frequency is 32 MHz (which I realize is not a multiple of 10 MHz) so I can't reach 400 kHz but I want to get as close to that as possible.
Now, in my I2C_InitStructure, I have set the clock speed to 400000 (400 kHz). I have enabled clock stretching and set the fast mode duty cycle after enabling I2C using:
I2C_StretchClockCmd(I2C2, ENABLE);
I2C_FastModeDutyCycleConfig(I2C2, I2C_DutyCycle_2);I must clearly be missing something because I am still only measuring 100 kHz on my SCL line.
I apologize if the answer to this question is obvious. I am very new at working with STM32 microcontrollers and I2C.
Thanks!
#stm32l1-i2c2017-06-16 08:15 AM
Sorry for posting! I have a problem in initializing I2C but the code I am using handles that and deInits and then re-Inits I2C and that was using a different value for I2C speed than what I thought it was.
TL;DR I don't actually have this problem. Setting the speed of I2C in the I2CInit function is the speed I measure on the SCL line.