LPCXpresso and Hard Fault
Hello all,
I am using LPCxpresso with an LPC1769 and Crossworks with the NXP LPC1000 CPU Support Package and CMSIS.
There is a hard fault exception that causes some headache to me.
The address where that hard fault comes up seems to be always the same, but it changes if some prior code is deleted.
I.e. the code at that acual address does not seem to be the reason for that exception.
To get a bit closer to the problem, I put some code to the hard fault handler and let it print some registers.
The result is this:
ACTLR=0
CPUID=412fc230
ICSR=400803
VTOR=0
AIRCR=fa050000
SCR=200
SHPR1=0
SHPR2=0
SHPR3=0
SHCRS=0
CFSR=400
HFSR=40000000
MMFAR=e000ed34
BFAR=e000ed38
CONTROL=0
MSP=10001a74
PSP=10001b38
HFSR tells mit that there is a "forced hard fault" and CRSR indicates an "illegal use of EPSR" and "the PC value stacked for the exception return points to the instruction that attempted the illegal use of EPSR".
As CONTROL equal 0, SP_main is the actual stack pointer.
SP == SP_main == 0x10001a84
SP points to a value of 0xd015429a.
0xd015429a is not a valid address for LPC1769.
But how does that help me to solve the problem?
Does anybody have an advice?
Henry
-
I found the code, but it didn't help. I knew - like you which line of code generated the fault. Like you, commenting things out or adding a nop didn't change the location.
What I found was the optimization level. It was set to "none" in debug mode. I set it to level 1 and the problem cleared up. I hope this helps.
-
Michael,
See https://rowley.zendesk.com/entries/46195-changing-optimisation-levels-causes-different-application-behaviour for a description of why a program may behave differently when changing the optimization level.
Regards,
Jon
Please sign in to leave a comment.
Comments
3 comments