Images Scientific Instruments Inc. sitemap







PIC Experimenter's Board Manual

Create Custome LCD Characters


Creating Custom LCD Characters

This is an advanced topic. Feel free to skip this section completely and move on to chapter 4 that is the begining of the Project chapters. If you ever have a need for custom characters you can revist this section.

The LCD has eight unused characters in RAM (Random Access Memory) that the user may define and use. Each character is defined by a 5x8-pixel pattern. The standard character generator of the HD44780 holds the 5x8-pixel patterns for its standard ASCII characters in ROM (Read Only Memory) and cannot be changed.

Each custom character is defined by an 5x8-pixel pattern. The pattern consists of five pixels across each row and eight rows high. Each 5-pixel row is represented by one byte. See the illustration below.

Bitmap LCD Matrix

Each box in the bit map has a value listed at the top of its column. When the box is colored in the value is added to all the colored boxes across each row and placed in the total value column to the right. Those total values are the byte values you will use to define your custom characters. Each character requires eight bytes of information to be defined. An up pointing arrow character is shown for example.

A worksheet is provided to help you to define the eight custom characters. You do not need to define all eight characters; you can define just one character if that is all you need.

Writing Custom Characters to CG RAM

Program examples follow this general outline.

1) Set pointer to beginning of CG RAM (memory location 64) on LCD display

LCDOUT 254,64

2) Send bytes representing bit patterns into CG RAM. The LCD controller automatically increments CG RAM addresses, as bytes are transmitted.

3) Leave CG RAM by issuing a control command such as clear LCD screen.

LCDOUT 254,1  'clear screen

4) The custom characters are the first 8 character positions in the LCD CG memory (memory locations 0 to 7). To print custom characters, use the character position. The following commands prints the first two customer characters.
LCDOUT 0  'Print 1st Custom Char.

LCDOUT 1  'Print 2nd Custom Char.

Program Listing:

'LCD Custom Characters

#CONFIG
  __config _CONFIG1,_INTRC_IO & _WDT_OFF &  _PWRTE_ON &  _MCLR_OFF & _LVP_OFF & _CP_OFF
#ENDCONFIG

osccon = %01110100    'Set-up internal oscillator at 8 Mhz
define OSC 8                  'define the oscillator frequency
ANSEL = %01100000     'Set RA0-RA4 as digital I/O for LCD leave RA5 and RA6 A/D

pause 1000

cnt VAR BYTE
char VAR BYTE

Data 4,0,4,4,8,17,17,14     'upside down question mark
Data 4,4,31,4,4,4,4,4       'cross
Data 4,14,21,4,4,4,4,0      'up arrow
Data 0,4,4,4,4,21,14,4      'Down arrow
Data 3,2,2,2,2,14,30,14       'music note
Data 14,17,17,31,27,27,31,0 'locked
Data 14,16,16,31,27,27,31,0 'unlocked
Data 30,28,28,18,1,0,0,0    'microsoft icon

lcdout 254,1
pause 1
lcdout 254,64
Pause 1
For cnt= 0 TO 63
Read cnt, char
lcdout char
Pause 1
Next

lcdout 254,1  'clear screen
Pause 4
lcdout 254,1,"Custom Graphics"

'Move to second line
lcdout 254,192 'move to line 2
Pause 4
For cnt= 0 TO 7
lcdout cnt," " 'Print character then space
Next
end

Previous Page | Next Page