cancel
Showing results for 
Search instead for 
Did you mean: 

Get witch line has called Error_Handler(void)

FMass.1
Associate III

Hi, I'm trying to develop a FW for one of my custom boards that has an ethernet interface.
I'm using STM32CubeIDE, I generated the code with the configurator, and without even writing a line of code, if I go into debug, during the initialization of the HAL the code immediately jumps to:

 

void Error_Handler(void){

 

I wanted to ask, Is there a way to know at which point the code jumped to Error_Handler(void), so as to try to understand where the problem is.
In other words, is it possible to run the code backwards or see from which line a certain function was called?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Sometimes the IDE parses things wrong. Look for the LWIP_ARP or LWIP_ETHERNET defines and ensure they're defined somewhere prior to the posted code.

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

View solution in original post

4 REPLIES 4

The more effective version would be to use the one that passes file and line, ie Error_Handler(__FILE__, __LINE__)

Otherwise you'll need to fish out the LR register to understand where it was called from, or step out via a return. Via LR you can perhaps use the .MAP or .LST file, or disassembly

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

If you set a breakpoint in there, you can examine the call stack in the debugger to see where it came from. Unwinding the stack at runtime can be done but is compiler-dependent and isn't very well supported on microcontrollers.

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

Through your heIp I managed to get to the point where Error_Handler() is called. Here:

FMass1_1-1701077571364.png

But I can't explain one thing, the point in question is this, but that whole block of code is grayed out, as if none of the LWIP_ARP or LWIP_ETHERNET macros were defined
How should I interpret this situation, should that code not be executed?
Did I do something wrong in the configurator?

TDK
Guru

Sometimes the IDE parses things wrong. Look for the LWIP_ARP or LWIP_ETHERNET defines and ensure they're defined somewhere prior to the posted code.

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