cancel
Showing results for 
Search instead for 
Did you mean: 

Two different I2C bus do not work together

TKota.3
Associate

Hi!

I use two I2C device on two different bus (I2C1 and I2C2) on a STM32G07B1 MCU.

The two bus works very well, if I use only one in my code.

But if I would like to use all of two, then it will go to HardFault from "__HAL_I2C_GET_FLAG".

I use the polling functions in the code.

I checked the signals with oscilloscope and logic analizator, too. The signal is very nice, no problem.

In the logic analizator I see, that the first i2c device works fine until I would like to switch on the second device on the other bus. The second device sends NOTHING.

This is my pinout:

0693W00000HohBeQAJ.pngMy I2C config:

0693W00000HohCIQAZ.png 

Do you have idea, what could I make?

Thank you!

Balazs

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Debug the hard fault, see why it was triggered and from where and go from there.

You can examine the extremely simple code for __HAL_I2C_GET_FLAG and verify it should not cause hard faults under normal circumstances. Verify that the handle you're passing to the function is valid and has not been mangled.

The I2C peripherals are independent. Using them both will not cause hard faults, the answer is elsewhere. Could be a buffer out of bounds write, stack overflow or something else.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

Debug the hard fault, see why it was triggered and from where and go from there.

You can examine the extremely simple code for __HAL_I2C_GET_FLAG and verify it should not cause hard faults under normal circumstances. Verify that the handle you're passing to the function is valid and has not been mangled.

The I2C peripherals are independent. Using them both will not cause hard faults, the answer is elsewhere. Could be a buffer out of bounds write, stack overflow or something else.

If you feel a post has answered your question, please click "Accept as Solution".
TKota.3
Associate

Hello!

Thank you for your fast reply.

The "buffer out of bounds write" was a great idea, I checked all of my arrays and almost the last one writes out of the bounds... :D

Thank you very much!