Hello,
I am using MCUXpresso to program my LPC1102 with a simple toggleLED. When I debug it, the microcontroller is getting flashed and the Debugger starts (I am using the MCU Link Probe). However immediatly after that the microcontroller returns a Hardfault and the debugger console states that the main function was not defined. So I had a closer look at the assembly file and it just contains the section definitions and setups, some frame dummy, an init function that does first push registers and then immediatly pops them and a finish function. But not a main function. This leads me to the conclusion that something must be wrong at compiling/linking/assembling.
Thanks in advance,
Nikolaus
> So I had a closer look at the assembly file and it just contains the section definitions and setups, some frame dummy, an init function that does first push registers and then immediatly pops them and a finish function. But not a main function.
If that was the case, the linker would report an error, and the build would fail.
Because the startup code requires a label _main which it executes at the end of the reset vector handler.
In my case (a LPC54628), defined in the source file startup_lpc54628.c).
> However immediatly after that the microcontroller returns a Hardfault and the debugger console states that the main function was not defined.
I would suggest to either debug through the startup code to see where the hardfault happens, or evaluate the respective SCB registers (https://wiki.segger.com/Cortex-M_Fault).
But usually, either the clock initialisation fails, or a memory address to an undefined/illegal address occurs.
The former (clock init fail) often happens with code intended for boards with different quartz settings or different clock sources. In other words, init code intended for different boards.