SBC In-System Programming: Information | VisISP-52 ISP Application
SBCMON Monitor/Operating System: Main Page | Manual
SBCMON-based Software: SBCMON Monitor | Keypad Demo | LCD Echo Demo | Hardware Clock | Software Clock
SBCMON-based PS/2 Software: PS/2 Comm Monitor | PS/2 Keyboard | PS/2 Mouse
ORDER 8052.com SBC: PCB, KIT OR BUILT SBC AVAILABLE FOR PURCHASE
Download LCD Echo Demo for SBCMON
You may download either the source code or the ready-to-use Intel-Hex version of the keypad demonstration program. The Intel-Hex version may be loaded into SBCMON's memory using the L or Q commands. Download the source ASM program if you'd like to see the code that makes the LCD demo work.
LCD Echo Demo Program Source (lcdecho.asm)
LCD Echo Demo Intel HEX (lcdecho.hex)
NOTE: This demo program requires SBCMON monitor program to run. Be sure to download SBCMON first, install on your SBC, and then run this demo from within SBCMON itself. This program may require additional modification in order to run without SBCMON.
This program receives input from the PC terminal program via the serial port and echos everything it receives to the LCD. Although in theory this sounds simple, the code implements some features that are not automatically handled by the LCD.
First, keep in mind that line 1 involves LCD memory addresses 00h through 0Fh while line 2 involves addresses 40h through 4Fh. Thus if a character is displayed at the last character position of line 1, the next character sent to the LCD will be not be displayed since it will be written to address 10h which is not visible. Thus a "wrap" feature must be implemented that makes sure that when the cursor goes off the end of line 1 that it is automatically positioned at the beginning of line 2.
Further, if the user types beyond the visible area of line 2 then the contents of the LCD must be scrolled. This is accomplished by copying the contents of line 2 to line 1, blanking out line 2, and positioning the cursor at the beginning of line 2.
The carriage return character is also a special case. If the user is typing on line 1 then the carriage return simply positions the cursor at the beginning of line 2. If the user is on line 2 and press a carriage return, however, then the program executes the scrolling code that was just described--effectively causing the LCD to scroll and leaving the cursor at the beginning of line 2.
The backspace character is handled by reading the current cursor position, decrementing it by one, and erasing the character found at that position and then leaving the cursor at that position. The code will ignore the backspace character if the cursor is already in the upper-left hand corner. Also, if the cursor is at the first character of line 2 then the backspace character must go to the last position of line 1--if it were not for this check then a backspace from line 2 character 1 (address 40h) would go to address 3Fh which is not visible on line 1. Instead, 40h must back up to position 0Fh.
All of these aspects are handled by the demo program. Thus you will find that typing into the PC terminal program will cause text to be displayed on the LCD in a very natural and logical manner.
NOTE: Before running this program, you must first use
the M0, M1, or M2 command in SBCMON to configure how the LCD is connected to
the SBC (direct-connect, memory-mapped, etc.)
Concepts Demonstrated by Program
This program demonstrates the following concepts:
- Receiving characters from serial port.
- Initializing LCD.
- Clearing LCD screen.
- Setting LCD cursor position.
- Reading LCD cursor position.
- Reading contents of LCD at cursor position.
- LCD vertical text scrolling.
- Handling backspace on multi-line display.