This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Hardfault Exception Debugging

The hardfault exception sometimes occurs during operation.

The register and stack value is like the following at the time of the hardfault exception occurrence.

  

According to this information, the LR(Link Register) is 0x080085CD before the hardfault exception.

So I think that the hardfault exception have occurred when the following code is executed.

0x080085CC    ADD    sp, sp, #0x14          : sp = 0x2000377C

0x080085CE    POP    {r4-r5, pc}

0x02020000(in the address 0x20003798 of the above stack area) is loaded into the PC by the POP instrunction ==> Hardfault Exception occurs.

The normal stack area value is like the following before POP instruction execution.

So the PC value should be 0x08008542(address 0x200038784) for the normal operaion.

I guess that the address 0x20003784 value would be overwrited the value 0x02020000.

Is it right?

Breakpoint like the following expression to stop the code execution just before the hardfault exception occur ?

BS WRITE * ((unsigned int*)0x20003784) == 0x02020000

How could I solve this problem(hardfault exception)?