Pfad: Home => AVR-Overview => 2-Line-LCD on STK500

Connecting a 2-line-LCD to a STK500 port

The develloper board STK500 doesn't come with a LCD interface for connecting a cheap display, like STK200 does. But even the STK200-LCD-port has some disadvantages: It requires talking to the LCD in memory mapped mode, which means, that the LCD interface blocks external SRAM space and requires slowing down the CPU with extra wait states. But it is easy to connect such a display to a port of the processor directly, without using memory mapping. It requires only 6 port bits, and the software is very easy, if you skip reading the display memory. The data sent to the LCD is divided in packages to 4 bits each. Hardware is rather easy, too. One disadvantage is that you have to do the timing without reading the display's enable bit, requiring some adjusted delay loops. But that is not too bad.


The hardware is shown in the following scheme:

LCD to STK-Port

So its only connecting the correct That's all for the hardware.


The software for talking to the LCD is completely separated in the file LCD4INCE.html in HTML-format and in the file Lcd4IncE.asm in source file format. The following routines are provided:
  1. Lcd4Init: This routine resets the LCD,
  2. Lcd4Chr: This displays the char in rmp on the LCD,
  3. Lcd4PBcd: This displays the packed BCD in rmp on the LCD,
  4. Lcd4ZTxt: This displays the null-terminated text in the flash memory on the LCD, using the Z pointer,
  5. Lcd4RTxt: This displays rmp chars in SRAM where Z points to.
The software can be included in an existing program. The header in the file lists the requirements, that the source file must fulfil to work correctly with the LCD rountines.

Test program

As a demonstration and test program a software clock has been programmed. This program displays date and time of a software clock on the LCD. The program is listed in the file LCDINCCE.html in HTML-format and in the file Lcd4IncCE.asm in source format. Sorry that you currently can not adjust the clock. If you like, you can add some lines of code to use the switches or the UART via the PC to adjust the software clock.

©2002 by