This question follows my note in regard to the failing flash memory access under the certain conditions. The question is the following. Why does the fault's stack frame does not match the expectations?
The exception occurs at the following instruction:
Upon the Bus Fault handler arrival I'm expecting to find a valid PC value in the stack frame, but instead I'm having the following content:
The stack frame pointed by the SP register has nothing in common with the core's state right before the exception. Moreover, the position which should be occupied by the PC value is pointing to the location beyond the RAM, which in the LPC5528 occupies the range 0x20000000 to 0x0x2002FFFF.
What is the reason?
Oops, my bad!
I didn't pay attention to the LR register. Its value in the exception handler is 0xFFFFFFBC, which according to the documentation says, that stack frame is located in the process stack, not in the main one. And I've been looking exactly at the latter in the previous message.
Here is how it looks like in fact:
The SP value right before fault is 0x200090E0. So the exception stack frame is right below the address. And there one may find the address of the instruction which has caused the fault. It is 0x0002C09C, like expected.