cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 I2c no kommunikation

sylviaheib
Associate II
Posted on November 10, 2011 at 14:38

Hi,

i try to let two stm32 Boards set all 2 seconds  a few bytes on the general call bus (0x00). Every board allone is doing his job, but when i put them together at the bus, there is nothing going on the I2C bus. First SDA and SDL stuck both at high, and after a little second SCL is going down and stay forever at low.

I am using the stm libs fom an2824 (the optimized i2c example). It is attached.

For  initialization I am using the I2C_LowLevel_Init() funktion to init I2C2 with the I2C speed 400khz. for Transmitting i am using the  I2C_Master_BufferWrite() funktion of the attached file.

Does anyone had the same Problem?

#i2c-stm32-scl-go-low
6 REPLIES 6
Posted on November 10, 2011 at 17:18

I don't have time to dig through this, but you only ever enable I2C2, and I'm pretty sure you need to use I2C_Cmd(I2Cx, ENABLE) prior to the I2C_Init(I2Cx, ..) for the peripheral to come up properly. At least in all the examples I've looked at. I2C on the STM32 is painful.

I2C_Cmd(I2C2, ENABLE);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sylviaheib
Associate II
Posted on November 10, 2011 at 18:37

// I2C Peripheral Enable

         I2C_Cmd(I2C2, ENABLE);

is written in the code, after initializing the I2C_InitStructure.

I2C1 I dont need, so i did not used the I2C_Cmd() funktion for I2C1

Posted on November 10, 2011 at 19:47

How exactly do you have these boards connected together? I2C devices, etc.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sylviaheib
Associate II
Posted on November 10, 2011 at 20:00

the two boards are both connecte with the backplane of a 19 inch casing

Posted on November 10, 2011 at 22:13

the two boards are both connecte with the backplane of a 19 inch casing

Thanks, that totally cleared up the electrical side for me.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
marta
Associate
Posted on January 31, 2014 at 16:44

Hey, Im fighting also with I2C problem for stm32f2xx. Maybe sb has a clue how to solve it or had the same problem.

My problem:

I want to have a communication between two boards in master and slave mode. I impemented both modes without interrupt and it works. But now all has to be done using interrupts. When I send data from master to slave, everything works fine. When I want to send data from slave to master here the problems starts. The ADDR and RxNE flag is not set but I get ACK (checked on osciloscope and Logic app). To check if it is a master fault, I checked how the same code works with EEPROM as a slave. Without interrupts everything works fine, both flags are set. But when master is ''done'' on interrupts just RxNE flag is set despite I get ACK. It looks like this event I2C_EVENT_SLAVE TRANSMITTER_ADDRESS_MATCHED is accomplished but at the same time

I2C_EVENT_MASTER_RECEIVER_ADDRESS_MATCHED is not.

I have no clue why it happens and I already spent a couple of days trying to solve this problem.

My code with interrupts is based on the stm32f2xx example.