Content originally posted in LPCWare by bavarian on Tue Nov 03 07:42:50 MST 2015
If the hard fault happens before main(), then it for sure happens in the code the linker inserts for initializing memory and relocating code. You don't see this code in your source code, only in assembler. When you jump from your source code into these embedded library code (at the end of the sys_init and just before main() ), you need to set the cursor into the assembler window to continue with stepping, otherwise it runs into the hard fault directly.
So something in your memory setup is not correct, the init code seems to overwrite something or writes outside memory boundaries.
You need to find the mismatch here.
The debugger should also be able to provide you with more info about the reason of the hard fault.
Regards,
NXP Support Team