2025-12-02 7:57 AM - last edited on 2025-12-02 9:06 AM by Andrew Neil
Split from this old, abandoned thread.
I see the same error. I'm using STM32F302, talking to MCF8329A using I2C. I can see the STM32 is reading the MCF8329A perfectly fine with no error when I power cycle it.
But when I run the firmware on debug mode on stmCubeIDE, I see the I2C doesn't respond, it responds with an error from I2C_WaitOnFlagUntilTimeout.
2025-12-02 9:12 AM
Probably the bus is in a bad state because the I2C bus was interrupted mid-transaction. A power cycle will clear it.
Put a HAL_Delay(500) before you do anything with the I2C. The debugger resets several times when you start a debug session.
2025-12-02 9:17 AM - edited 2025-12-02 9:20 AM
Welcome to the forum.
Rather than wake up an old abandoned thread, it's better to start your own - then you can mark the solution when the problem is solved.
You say it's the "same error", but that thread never established what the actual problem was. In fact, the poster never engaged at all beyond asking the rather vague question!
You need to give some more details of your setup - please see: How to write your question to maximize your chances to find a solution
What, exactly, do you mean by "run the firmware on debug mode" ?
Have you used a logic analyser to compare what happens on the I2C wires when it's working against what happens when it fails ?
See this for when things work with debug, but not without:
2025-12-02 9:22 AM
The delay of 500 isn't helping. Before I use the I2C in the firmware, I have asked HAL_I2C_IsDeviceReady(), for which I got a HAL_OK response meaning the I2C is working fine.
But when I start reading/writing to MCF8329A it fails every time (During debug mode, FYI no breakpoints applied).
Its very curious that it works when I power cycle, with great ease.
2025-12-02 9:39 AM - edited 2025-12-02 9:41 AM
Don't expect I2C to work correctly when single-stepping through code. There are timing agreements between master and slave that need to be met. No reason for it not to work in debug mode provide you are not using breakpoints or other things that interrupt the bus.
Show relevant code.
A logic analyzer trace of SCL/SDA would show you what's happening on the line.