cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 I2C issue - solved

zexx86
Associate II
Posted on March 20, 2015 at 18:41

Hello,

we are migrating our device from STM32F1 to F4 (415RGT6).

Basically wiring is very similar, connected peripherals too.

We have one device that communicating over I2C bus, but with same code it is unable to work with new processor.

Of course, there are some differences - I2C3 instead of I2C2, etc. It should work, but does not.

Initialization code looks like this: http://pastebin.com/5MRFkfbE

It seems that I can get WHOAMI response from I2C device, so connection is working somehow. Then I can write some data to it.

But then I am getting:

I2C_GetFlagStatus (I2C_MPU6050, I2C_FLAG_BUSY)

so it is always BUSY after lets say 1 read and 1 write.

My I2C code is able to reset whole I2C and communication but it does not help. Whats more there shouldn't be any BUSY flag.

In this state, I2C register SR1 has value 0x44 and SR2 value 0x3.

SR1 value means:

I2C_FLAG_RXNE

I2C_FLAG_BTF

flags are present.

SR2 has probably:

I2C_FLAG_BUSY

I2C_FLAG_MSL

if I am correct.

I use HSE 8Mhz crystal @ 168Mhz core clock, Flash Latency 5.

There are Pull Up resistors 4K7 for SDA and SCL.

What could be wrong?

Thank you very much

1 REPLY 1
zexx86
Associate II
Posted on March 20, 2015 at 22:36

Problem solved!

Issue was caused in reading sequence.

It is not 100% same with one used for F1 line.