MCUXpresso LPC1102 build not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MCUXpresso LPC1102 build not working

2,769 次查看
Nikolaus
Contributor I

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

标签 (1)
0 项奖励
回复
2 回复数

2,752 次查看
frank_m
Senior Contributor III

> 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.

0 项奖励
回复

2,738 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Nikolaus 

 

Recommend debug from startup code step by step, check where it run to Hardfault refer to Frank's suggestion.

 

BR

Alice

0 项奖励
回复