2021-12-15 04:22 AM
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:
My I2C config:
Do you have idea, what could I make?
Thank you!
Balazs
Solved! Go to Solution.
2021-12-15 05:59 AM
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.
2021-12-15 05:59 AM
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.
2021-12-16 12:04 AM
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!