What is the routine that generates the hardfault_handler ecception ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What is the routine that generates the hardfault_handler ecception ?

1,039 Views
_Ferrari_
Contributor IV

Dear all,


I am developing a project based on the LPC5526 processor.

Sometimes, during debugging, a HARDFAULT_HANDLER exception is generated, as shown in the image below.

Unfortunately, I cannot figure out at which execution phase the exception is generated, and in particular, the routine that generated it (there is no useful information in the call stack window)

Have you ever had problems like this? How did you solve them?

Thank you very much for your help and collaboration.

Best regards.

 

_Ferrari__0-1693405719045.png

 

0 Kudos
5 Replies

808 Views
ErichStyger
Senior Contributor V

Hi @_Ferrari_ ,

I recommend that you add and use a special hardfault handler. I wrote about it here:

https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/

You can skip the first part about Processor Expert, and use the extend handler described in the second part of the article. The source code of it can be found here:

https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/src/McuHardFault.c

That way you should see the PC and LR causing the hard fault.

I hope this helps,

Erich

0 Kudos

1,008 Views
Miguel04
NXP TechSupport
NXP TechSupport

Hi @_Ferrari_ 

Can you provide the details of the software you are using? While debugging, what is the code line that is causing the fault?

Best Regards, Miguel.

0 Kudos

986 Views
_Ferrari_
Contributor IV
I'm developing a software in 'C' and I'm not using FreeRTOS.
Unfortunately I don't know what code line causes the faut. Is there any register/memori location/Debbugging ifìnfo that I have to analyze to know what code line caesed the fault ?

thank you for your help and cooperation
rehards
0 Kudos

954 Views
Miguel04
NXP TechSupport
NXP TechSupport

Hi @_Ferrari_ 

The fault could be caused, for example, writing into a peripheral register that is not initialized.

Please debugg your code step-by-step with this MCUXpresso tool. Instead of clicking Resume, click step into and tell me where the fault is occured.

Miguel04_0-1693585313117.png

Can you tell me what are you coding? We could have a SDK example that can guide you.

Best Regards, Miguel.

0 Kudos

927 Views
_Ferrari_
Contributor IV
Dear Miguel,
Thank you for youre reply.
The software that I'm developing is complex: it uses USB, SPI, I2C, FLASH, Digital I/O, Analog input and comparators. Unfortunately the 'HARDFAULT_HANDLER exception' is generated only once after months. But, if I have well undesrstood, ther is no possibility to know why the exception was generated simply looking the the debbugger information (the message in the red ellipse of the picture)

Thank you very much for your help and cooperation
regards
0 Kudos