AnsweredAssumed Answered

MCU HardFault if not erased first

Question asked by Matt Lang on Jan 4, 2019
Latest reply on Jan 8, 2019 by Matt Lang

I have the LPCXpresso54608 OM13092 evaluation board. 

 

I created a custom PCB with the LPC54605J256 MCU.

 

If I take a simple demo application such as the lpcxpresso54608_hello_world from the SDK 2.5.0, it works great on the eval board. But not on my custom PCB.

 

On the custom PCB the demo app runs just fine the first time around. I can load code and step through it like normal. Semihosting is working, it repeats everything I send to it like the demo is is supposed to do.

 

Then I use the terminate button to stop debugging (The red square button). Then in the Quickstart window I hit "Debug" in the "Debug your project" section. I then choose my JLink Ultra+ debugger and hit debug, it programs like normal, but then it goes straight to the HardFault handler. In this case the semihosting hardfault handler since I have that included.

 

I do instruction stepping mode to go through the assembly code that is in the hardfault handler. And it gets stuck on this line. No matter how many times I hit step, it stays here:

 

Debugging:

 

If I put a break point at the "ResetISR" in startup_lpc54608.c and start assembly stepping. It calls the CMSIS SystemInit() and this line causes a hardfault: With the image below, if I hit step one more time it causes the fault. 

 

 

One solution:
I found that if I erase the MCU first on the CUSTOM PCB, then debug, it works every time. If I use the following to erase:

Then debug, it works. 

 

I only need to do this on my custom PCB. I do NOT have to do this on the eval board. The eval board just works whenever I hit debug. Power cycling the custom PCB does not work either.

 

The only difference between my PCB and the eval board is that my PCB has the LPC54605J256 MCU instead of the LPC54608J512. I edited the memory regions to have the correct 256k flash and 136k RAM for my target and that did not fix it either.

 

Any ideas of what might be going on here?

 

MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] 

Outcomes