About me




















Defining Custom Characters

The text below is a part of LCD Serial Backpack App Note No. 2 from Scott Edwards Electronics, Inc. In case you wondered, The LCD Serial Backpack is a daughterboard that attaches to standard character LCD modules. It receives data serially and displays it on the LCD. The Backpack supports any alphanumeric LCD up to 80 screen characters (e.g. 4 lines by 20 characters). It accepts serial data at 2400 or 9600 baud (switch selectable). It is sold by itself, or preinstalled to high-quality 2x16 LCD modules.

I edited the application note slightly to suit paralell LCD modules. You can find the original document in PDF format at www.seetron.com .

ALPHANUMERIC LCDS are inexpensive and easy to use. But there are times when you'd like to add some graphical pizzazz to your display without the expense and code overhead of a graphics display. With a little ingenuity, you may find that the block-graphics capabilities of standard LCDs can fill the bill without busting your budget.

Character-Generator ROM and RAM.

When you send the ASCII code for a character like "A" to an LCD module, the module's controller looks up the appropriate 5x8-pixel pattern in ROM (read-only memory) and displays that pattern on the LCD. That character-generator ROM contains 192 bit maps corresponding to the alphabet, numbers, punctuation, Japanese Kanji characters, and Greek symbols. The ROM is part of the main LCD controller (e.g., HD44780, KS0066, etc.), is mask-programmed, and cannot be changed by the user. The manufacturers do offer alternative symbols sets in ROM for European and Asian languages, but most U.S. distributors stock only the standard character set shown in the LCD Serial Backpack manual. Alphanumeric LCD controllers do not allow you to turn individual pixels on or off-they just let you pick a particular pattern (corresponding to an ASCII code) and display it on the screen. If you can't change the ROM and you can't control pixels, how do you create graphics on these LCDs? Easy. There's a 64-byte hunk of RAM (random-access memory) that the LCD controller uses in the same way as character-generator (CG) ROM. When the controller receives an ASCII code in the range that's mapped to the CG RAM, it uses the bit patterns stored there to display a pattern on the LCD. The main difference is that you can write to CG RAM, thereby defining your own graphic symbols.

Each byte of CG RAM is mapped to a five-bit horizontal row of pixels, and LCD characters are typically eight rows high, so 64 bytes of CG RAM is enough to define eight custom characters. These characters correspond to ASCII codes 0 through 7, which normally serve as control codes for marking the beginning of a serial transmission or ringing the bell on a terminal. Since these have no meaning to an LCD module, the designers appropriated them for CG RAM.

When an LCD is first powered up, CG RAM contains random bits garbage. If necessary,you may clear CG RAM by writing 00 into each CG RAM cell.

Writing to CG RAM.

Writing to CG RAM is a lot like moving the cursor to a particular position on the display and displaying characters at that new location. The steps are:

  • Reset RS and R/W pins of the LCD to prepare the LCD to accept instructions
  • Set the CG RAM address by sending an instruction byte from 64 to 127 (locations 0-63 in CG RAM).
  • Switch to DATA MODE by changing setting the RS pin
  • Send bytes with the bit patterns for your symbol(s). The LCD controller automatically increments CG RAM addresses, just as it does cursor positions on the display.
  • To leave CG RAM,switch to COMMAND MODE to set address counter to a valid display address (e.g. 128, 1st character of 1st line); the clear-screen instruction (byte 1); or the home instruction (byte 2). Now bytes are once again being written to the visible portion of the display.
  • To see the custom character(s) you have defined, print ASCII codes 0 through 7.

Bitmap layout example :