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

Code works fine in optimzation while go to hardfault in levl 0 optimzation

HI,

My code works fine in optimzation for time level . But in level - 0 optimzation it goes to hardfault before entering main.

I am using LPC1317, here is reset handler for this.

Reset_Handler   PROC
                EXPORT  Reset_Handler             [WEAK]
                IMPORT  SystemInit
                IMPORT  __main
                LDR     R0, =SystemInit
                BLX     R0
                LDR     R0, =__main
                BX      R0                                -- STAT whre problem
                ENDP

After "BX R0" code goes into hardfault with level0 however works fine in level3+cross+time optimztion.

In both optimzation value of R0 is 0x000000C1.

I guess its due to R/W data 248 bytes. However watchdog is off by deafult.
I don't initialize any var during declaration. However even due to level 0 optimzation ZI data goes to R/W data.