How to get console output while debugging application in lpcexpresso?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get console output while debugging application in lpcexpresso?

2,622 Views
jacobmckay
Contributor II

I have downloaded LpcExpresso and the NHS3100 SDK, followed the quickstart to flash the 'blinky' program to the nhs3100, and now I'm stuck trying to read the console output of the app_example_dp_ndeft2t (the example that sends/receives NFC messages).

It's been years since I've done any c++ so forgive me if this is supposed to be trivial :smileysilly:

Anyway, I can debug the application, stop on breakpoints and inspect their values, but the program has many calls to Trace_Printf that would be rather convenient if they showed up in my LpcExpresso.  I'm thinking the answer lies somewhere with "Semihosting" or "SWO Trace Config" both of which are new concepts to me, and both of which I have tried to follow instructions to get up and running with in LpcExpresso and the example applications.

Can anyone give me a push in the right direction?

6 Replies

1,723 Views
jacobmckay
Contributor II

I changed every call from Trace_Printf to printf and now I have console output for the sample application while debugging.

0 Kudos

1,723 Views
aresmarser
Contributor III

Hi Sirs,

How do you solve it?

Could you be kindly to share how I should setup the config to printf for "console output"?

Many thanks,

Arna

0 Kudos

1,723 Views
jacobmckay
Contributor II

Replace statements like this: 

Trace_Printf("Received TEXT Record (len = %d, restricted to 32): %.*s\n\r", payloadLength, 32, pPayloadStart);

With statements like this:

printf("Received TEXT Record (len = %d, restricted to 32): %.*s\n\r", payloadLength, 32, pPayloadStart);
0 Kudos

1,723 Views
aresmarser
Contributor III

Hi Jacob,

Thanks for your reply.

Actually I did do that just like what you said.

For example, I tried the project "app_demo_dp_blinky" and added below statement in blue in the mainblinky.c file main function:

------

#include <stdio.h>
#include "board.h"
int main(void)
{
    Board_Init();
    /* Optional feature: send the ARM clock to PIO0_1 */
    Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_PIO0_1, IOCON_FUNC_1);
    Chip_Clock_Clkout_SetClockSource(CLOCK_CLKOUTSOURCE_SYSTEM);
    /* Blink with a period of 250ms+250ms, or 2Hz */
    while (1) {
     printf("LED_Toggle\r\n");
        LED_Toggle(LED_RED);
        Chip_Clock_System_BusyWait_ms(250);
    }
    return 0;
}
------
But it met the compiling error:( as below.
Any idea or suggestion?
******
10:24:47 **** Incremental Build of configuration Debug for project app_demo_dp_blinky ****
make -r -j4 all
Building target: app_demo_dp_blinky.axf
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -L"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_board_dp\Debug" -L"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_chip_nss\Debug" -Xlinker -Map="app_demo_dp_blinky.map" -Xlinker --gc-sections -mcpu=cortex-m0plus -mthumb -T "app_demo_dp_blinky_Debug.ld" -o "app_demo_dp_blinky.axf"  ./src/crp.o ./src/mainblinky.o   -llib_board_dp -llib_chip_nss
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(fpprintf.o): In function `printf':
fpprintf.c:(.text.printf+0x38): undefined reference to `__sys_write'
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(_deferredlazyseek.o): In function `__flsbuf':
_deferredlazyseek.c:(.text.__flsbuf+0x88): undefined reference to `__sys_istty'
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(_writebuf.o): In function `_Cwritebuf':
_writebuf.c:(.text._Cwritebuf+0x16): undefined reference to `__sys_flen'
_writebuf.c:(.text._Cwritebuf+0x26): undefined reference to `__sys_seek'
_writebuf.c:(.text._Cwritebuf+0x3c): undefined reference to `__sys_write'
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(alloc.o): In function `_Csys_alloc':
alloc.c:(.text._Csys_alloc+0xe): undefined reference to `__sys_write'
alloc.c:(.text._Csys_alloc+0x12): undefined reference to `__sys_appexit'
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(fseek.o): In function `fseek':
fseek.c:(.text.fseek+0x18): undefined reference to `__sys_istty'
fseek.c:(.text.fseek+0x3c): undefined reference to `__sys_flen'
collect2.exe: error: ld returned 1 exit status
make: *** [app_demo_dp_blinky.axf] Error 1
10:24:47 Build Finished (took 405ms)
******
Thanks,
Arna
0 Kudos

1,723 Views
thefallguy
Contributor IV

Suggest you read this FAQ:

https://community.nxp.com/thread/389070 

1,723 Views
aresmarser
Contributor III

Thank you, Fall Guy. 

I got the answer.

0 Kudos