cancel
Showing results for 
Search instead for 
Did you mean: 

Getting hard fault handler issue while running

Devika Raju
Associate II

Hi all,

I am working on a project which is based on freertos on stm32l476rg. I have added STM32CubeExpansion_CELLULAR_V5.2.0 into my project and while running I am getting hard fault handler before control comes to main function.

These are the remedies I tried

  • Increased stack size and checked
  • I referred this document to check the hard fault handler issue (page number 4)
  • 0693W000008G0jjQAC.png

https://www.segger.com/downloads/application-notes/AN00016 shown in the above picture, I changed the variable 'var' to 1 in runtime in expression window in the stm32cubeide to find the root cause of hard fault handler while stepping out of the breakpoint which I set in the line number 96 in the code.

I checked the fault analyzer also and here I attached fault analyzer window

0693W000008G0lVQAS.png 

I am not getting where could be the issue? Please can anybody help me out?

2 REPLIES 2

You've got to look at the processor registers, and the location of the faulting instructions, and do a disassembly of those.

Before main you have the code in startup.s and SystemInit()

Turn off run-to-main, and step the coding from the Reset_Handler, check that you aren't trying to initialize memory that isn't enabled, ie QSPI, memory beyond scope of FLASH or RAM.

Check you aren't using an FPU instructions before enabling the co-processor.

Check you aren't using a broken or misaligned stack pointer.

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

Thank you for your reply.

I tried as you told. I did step the coding from Reset_Handler. I set a breakpoint at where SystemInit() is called (in the startup.s) and while stepping into the function, the control goes to hard fault handler. I am attaching the snippet of disassembly, Registers and SFRs tab in stm32cubeide.

Still I am unable to solve the issue. can you help me please?

0693W000008G3WnQAK.png0693W000008G3WiQAK.png0693W000008G3WdQAK.png