cancel
Showing results for 
Search instead for 
Did you mean: 

FSM bug in STM32 ?

Carter Lee
Associate III
Posted on September 14, 2017 at 11:02

HI.Now I'm trying to debug code with break pointers in STM32F4 kit.

As you can see the below code, I put some break point in my code.

But problem is taht FSM go broken. 

At the line 437, I go next step (F11),

0690X00000608DbQAI.png

But it goes to 442 line. It's a absolutely different state.

Even it does not go break statement.

0690X00000607FIQAY.png

I guess that compiled assembler code and C code are different working.

But I can't understand it, does this make sense..? what am I supposed to do to resolve

4 REPLIES 4
kraiskil
Associate III
Posted on September 14, 2017 at 11:15

If I understood correctly, this is normal behaviour, when you have compiled your code with optimizations.

Switching your optimization flag (-O, if this is gcc) to zero (-O0) should make the compiled code more debug-friendly.

Posted on September 14, 2017 at 11:19

Thanks let me check more to figure out 

Posted on September 14, 2017 at 15:18

With gcc, -Og may be more helpful than -O0.

Posted on September 14, 2017 at 19:47

There is a one-to-many relationship between C lines and assembler lines, the debug data doesn't fully decode this and there can be code reordering, replication or removal. For a more linear flow turn off optimization.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..