Hello,
I have a problem that I'm hoping someone might be able to give me pointers on how to debug.
I have the simplest firmware possible (blink and LED in a while(1) and this firmware works as expected on an EA development kit for the LPC1788.
I have a custom LPC1788 board and I can download the firmware to the board but when I start the debug session the PC goes straight to the HardFault_Handler.
If I manually change the PC to the Reset vector the firmware runs as expected on the custom board. (i.e. the LED blinks and I can stop the execution with the uVision debugger)
Does anyone have any idea why this might happen?
Does anyone have any trouble shooting tips I could try?
Thanks.
Marc
Maybe:
check NMI pin; set FAULTMASK to 1; put some NOP at the beginning;
Hi John,
How/Where would I set the FAULTMASK to 1? In an initialization file? Because as soon as the debugger starts the PC goes to the HardFault_Handler address.
What should I be checking for on the NMI pin? For the RESET and NMI pins I have them pulled high with the ISP able to pull them LOW for use with FlashMagic or the like...
Also the NOP at the beginning did not change anything. It never even reaches the NOPs
Still at a loss...
M
The Definitive Guide to the ARM Cortex-M3 Joseph Yiu
Exception Type | Priority Reset | -3 (Highest) NMI | -2 Hard fault | -1
FAULTMASK
A 1-bit register. When this is set, it allows only the NMI, and all interrupts and fault handling exceptions are disabled. The default value is 0, which means that no masking is set.
To access the PRIMASK, FAULTMASK, and BASEPRI registers, the MRS and MSR instructions are used. For example: MRS r0, BASEPRI ; Read BASEPRI register into R0 MRS r0, PRIMASK ; Read PRIMASK register into R0 MRS r0, FAULTMASK ; Read FAULTMASK register into R0 MSR BASEPRI, r0 ; Write R0 into BASEPRI register MSR PRIMASK, r0 ; Write R0 into PRIMASK register MSR FAULTMASK, r0 ; Write R0 into FAULTMASK register The PRIMASK, FAULTMASK, and BASEPRI registers cannot be set in the user access level.
Another method 'CPS' instruction: (rock.song)
CPSID I ;PRIMASK=1 CPSIE I ;PRIMASK=0 CPSID F ;FAULTMASK=1 CPSIE F ;FAULTMASK=0
How/Where would I set the FAULTMASK to 1? In an initialization file?
I am not familiar with the debug-ini-file, sorry.
I assume that, the simplest firmware does not work on your custom LPC1788 board. If so, use Assembly or Inline/Embedded Assembly to set the FAULTMASK to 1, and test it with your custom LPC1788 board.
My knowledge on the related topic is very limited. My idea may NOT be good.
Sometimes, the debugger can NOT set the processor status properly at the correct timing, some NOP may give the debugger enough time to talk to the processor.
What should I be checking for on the NMI pin?
I am software engineer, my intention is to insure that, hardware does not generate a NMI.
I noticed this:
http://www.keil.com/dd/chip/5325.htm
NXP (founded by Philips) LPC1788
NOTE Simulation for this device is provided by the default peripheral simulation driver. Complete peripheral simulation is not available at this time.
The following on-chip peripherals are not simulated. Flash Memory I2C Interface Memory Accelerator Module Memory Mapping Control