LCD Commands

Commands for controlling LCD character display modules. These commands work with most 1-line, 2-line or 4-line LCD modules that use the KS0066, HD44780 or SPLC780 controller.

See LCD Display Modules in the Special Device Support chapter for hardware setup, wiring diagrams, and usage examples.

Initialisation

LCD INIT d4, d5, d6, d7, rs, en

Initialise an LCD character display module for use. This command will work with most 1-line, 2-line or 4-line LCD modules that use the KS0066, HD44780 or SPLC780 controller (however this is not guaranteed).

'd4' to 'd7' are the I/O pins that connect to inputs D4 to D7 on the LCD module (inputs D0 to D3 should be connected to ground). 'rs' is the pin connected to the register select input on the module (sometimes called CMD). 'en' is the pin connected to the enable or chip select input on the module. The R/W input on the module should always be grounded.

The above I/O pins are automatically set to outputs by this command. When the module has been initialised data can be written to it using the LCD command.

Display Control

LCD line, pos, text$

Display text on an LCD character display module that has been previously initialised with LCD INIT.

'line' is the line on the display (1 to 4) and 'pos' is the character location on the line (the first location is 1). 'text$' is a string containing the text to write to the LCD display.

'pos' can also be C8, C16, C20 or C40 in which case the line will be cleared and the text centred on a 8, 16, 20 or 40 character display. For example: LCD 1, C16, "Hello"

LCD CLEAR

Erase all data displayed on an LCD character display module that has been previously initialised with LCD INIT.

LCD CLOSE

Terminate the LCD function and return all I/O pins to the not configured state. The LCD must have been previously initialised with LCD INIT.

Raw Mode Commands

LCD CMD d1 [, d2 [, etc]]

Send one or more bytes to an LCD display as commands. Each byte is a number between 0 and 255 and must be separated by commas.

The LCD must have been previously initialised using the LCD INIT command. This command can be used to drive a non-standard LCD in "raw mode" or to enable specialised features such as scrolling, cursors and custom character sets. You will need to refer to the data sheet for your LCD to find the necessary command values.

LCD DATA d1 [, d2 [, etc]]

Send one or more bytes to an LCD display as data. Each byte is a number between 0 and 255 and must be separated by commas.

The LCD must have been previously initialised using the LCD INIT command. This command can be used to drive a non-standard LCD in "raw mode" or to enable specialised features such as scrolling, cursors and custom character sets. You will need to refer to the data sheet for your LCD to find the necessary data values.