error: Hard Fault Handler

HI,currently i am working on project based on stm32f407 chip.my development work has been stopped since two days as i have stuck in hard fault handler. Please  guide me how to trace the fault ???i tried every possible way i could.but result in nothing.Pls help me out.thanks in advance

Parents
  • Hi,

    I believe you would like to "get" the actual PC that made the hardfault and not the current PC.

    As the stm32f407 is based on Cortex-M4, I believe, you may find the misbehave PC point by looking at the LR register and decide if the PSP or MSP is

    the actual stack that is important.

    Then open Memory window and and ump MSP or PSP according to LR.

    You will find the PC at address (MSP or PSP) + 6 dwords

    All of that can be done from the debugger at the hard-fault interrupt breakpoint.

    I know a C code is better, but, writing that code is vital only if you plan to "have" lots of hard-faults ... :-)

Reply
  • Hi,

    I believe you would like to "get" the actual PC that made the hardfault and not the current PC.

    As the stm32f407 is based on Cortex-M4, I believe, you may find the misbehave PC point by looking at the LR register and decide if the PSP or MSP is

    the actual stack that is important.

    Then open Memory window and and ump MSP or PSP according to LR.

    You will find the PC at address (MSP or PSP) + 6 dwords

    All of that can be done from the debugger at the hard-fault interrupt breakpoint.

    I know a C code is better, but, writing that code is vital only if you plan to "have" lots of hard-faults ... :-)

Children
No data