Skip to the content of the web site.

LCD Hello World

This is a simple Hello World program that uses the LCD screen on the Keil evaluation board. The relevant files you will need are available in the source directory, both as individual files and as a zipped file.

#include <lpc17xx.h>
#include "GLCD.h"

int main( void ) {

	SystemInit();
	
	GLCD_Init();
	GLCD_Clear( Blue );
	
	/* GLCD_DisplayString( row, column, font_size (0 or 1), string ) */

	GLCD_DisplayString( 1, 1, 0, "Hello world!" );
	GLCD_DisplayString( 5, 7, 0, "It's a beautiful day." );

	while ( 1 ) {
		/* An emebedded system does not terminate... */
	}
}

To run this code, create a new directory and copy the code in the zip file to the directory. Create a new μVision4 project in that directory with a name like LCDHelloWorld.uvporj. When you create the project, you should allow the system to include the startup code. I have renamed the target Target1 to LCD Hello. I renamed the first group as Startup Code and added two more groups: System Code and Source Code.

This time, you must add both system_LPC17xx.c and GLCD_SPI_LPC1700.c to the System code group.

Embedded systems do not terminate, and therefore this routine ends in an infinite loop, as did the previous main.c function.

Having selected Build Target (F7) Build target files and then Download Download code to flash memory, the μVision4 IDE has the text in the Build Output window shown in Figure 1.

The μVision4 IDE with LCD_hello.c open and in the Output Build panel, the text 'Build target 'Target 1' compiling Hello.c...  linking...  Program Size: Code=4432 RO-data=6508 RW-data=12 ZI-data=612  '.\LCDHelloWorld.axf' - 0 Errors, 0 Warning(s).  Load 'C:\\Keil\\dwharder\\LCDHelloWorld\\LCDHelloWorld.axf' Erase Done.  Programming Done.  Verify OK.'
Figure 1. Building and downloading the binary to the board.

You now need only push the reset button on the Keil MCB1700 evaluation board, shown in Figure 2.

The reset button on the Keil MCB1700 evaluation board.
Figure 2. The reset button on the Keil MCB1700 evaluation board.

The text will appear on the screen using a proportionally spaced font with characters 8 × 6 pixels in size. Changing the third argument of GLCD_DisplayString to 1 will result in characters 24 × 16 pixels in size.

Note: the LCD screen is 240 × 320, allowing for 10 × 20 characters of the larger font to appear on the screen and 30 × 53 characters of the smaller font.

For more information on the Graphics LCD library, see GLCD. We are using commands