User manual
LPCXpresso Experiment Kit - User’s Guide
Page 50
Copyright 2013 © Embedded Artists AB
Figure 22 – Semihosting Console Output
Create a program that determines the Endianness of the microcontroller and prints the result. Assume
we have a 32-bit number: 0x0AC0FFEE in hexadecimal notation. The table below illustrates how the
bytes are stored differently between a big and little Endian system.
Memory address
n
n+1
n+2
n+3
Big-endian
0x0A
0xC0
0xFF
0xEE
Little-endian
0xEE
0xFF
0xC0
0x0A
Now think of a solution how to test this.
Tip: Create an unsigned int-pointer and an unsigned char-pointer. Let these pointers point to the same
unsigned int-variable. Write a value in the unsigned int-variable with the unsigned int-pointer. Then
read out the four parts via the unsigned char-pointer.
What Endian does the LPC111x has (little or big endian)? ___________________________
The printf() function works like normal. It is possible to output strings and general expressions. Verify
that this works.
Note that Semihosting affects code execution performance severely. Every time a data transfer takes
place, the execution of the program stops during the transfer. The microcontroller cannot do anything
useful whilst waiting on each transfer to complete. The blocking time depends on the LPCXpresso IDE
(and the PC it executes on). Do not use printf() and Semihosting in time critical loops. In the next lab, a
performance test will be carried out to get a feeling for the transfer rate.
Adding printf()-functionality to a small embedded system is a trade-off between flexibility and code
size. The full implementation of printf() is very large, especially if floating point is supported. NXP has
created an application note that covers basic techniques to reduce the size of code. Many things are
covered along with a reduced size printf()-implementation that is supported in the LPCXPresso IDE.
The application note is named: AN10963: Reducing code size for LPC11XX with LPCXpresso