Hard fault handler problem - Cortex-M0+

Hi all,

I use generic Cortex-M0+ with ARM Development Studio 5.

I want to create a hard fault handler that prints out call stack list (unwind the stack).

At first I try to find just the return address from the stack (the cause of the hard fault) but it doesn't seem to work. I work without RTOS so I'm supposed to be in Handler mode and always use the MSP stack. Regardless I check the bit in the control register and it, as expected, indicates the MSP stack is in use. The problem is that the MSP stack holds no return address (I force hard fault so I know the supposed return address).

I check the PSP stack as well that has some valid return address but not the correct one.

Here is my code [NMI is routed to hard fault handler as well]:

Any ideas why I don't get the return address?

How can I unwind the stack and create a call stack list?

Thank you

0