This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC1788 HardFault on 3rd assembly instruction

In my current project I use uVision 5.38 and the compiler default V6 compiler. As a controller I have a LPC1788 that crashes to the HardFault_Handler on the 3rd (or 4th) assembly instruction.

At the start of the project I have the following instructions from startup_LPC177x_8x.s

LDR     R0, =SystemInit
BLX     R0

In SystemInit I have the following instructions

PUSH     {r7,lr}
MOVW     r1,#0xC1A0
MOVT     r1,#0x400F
MOVS     r0,#0x21

However if I press F11 once I am on the "PUSH {r7, lr}" instruction the next instruction is at address 0x00000188, in other words HardFault_Handler. Where the cpu get's "stuck" on the B instruction (to the same location).

If I try the blinky demo (for the LPC1788) the SystemInit looks like this

PUSH     {r4-r8,lr}
MOVW     r5,#0xC0C4
MOVT     r5,#0x400F
MOVS     r0,#0x21

This code does not trigger a HardFault_Handler.

Any suggestions on how to fix this?

Parents
  • My SP and other registers are set as follows:

    My Memory settings are as follows:

    And finally from my .map file

        Heap_Mem                                 0x10001980   Data       4194304  startup_lpc177x_8x.o(HEAP)
        HEAP                                     0x10001980   Section    4194304  startup_lpc177x_8x.o(HEAP)
        Stack_Mem                                0x10401980   Data         512  startup_lpc177x_8x.o(STACK)
        STACK                                    0x10401980   Section      512  startup_lpc177x_8x.o(STACK)
        __initial_sp                             0x10401b80   Data           0  startup_lpc177x_8x.o(STACK)
        FPCCR                                    0xe000ef34   Number         0  irq_armv7m.o ABSOLUTE

    So the stack pointer seems OK?

Reply
  • My SP and other registers are set as follows:

    My Memory settings are as follows:

    And finally from my .map file

        Heap_Mem                                 0x10001980   Data       4194304  startup_lpc177x_8x.o(HEAP)
        HEAP                                     0x10001980   Section    4194304  startup_lpc177x_8x.o(HEAP)
        Stack_Mem                                0x10401980   Data         512  startup_lpc177x_8x.o(STACK)
        STACK                                    0x10401980   Section      512  startup_lpc177x_8x.o(STACK)
        __initial_sp                             0x10401b80   Data           0  startup_lpc177x_8x.o(STACK)
        FPCCR                                    0xe000ef34   Number         0  irq_armv7m.o ABSOLUTE

    So the stack pointer seems OK?

Children