The next section is the heart of this program. In this
block of code, the custom characters are created and
stored in the LCD character memory locations 0 through 7.
Each character takes eight bytes of data, for a total of 64
bytes (eight characters times eight bytes).
To do this, we first have to point to location zero of the
Character RAM. We do this with the LCDWRITE command,
again by sending the “CGRAM” pointer. We don’t have
to add an address value, since it defaults to the zero or
‘*** Create Custom Characters in LCD memory locations 0-
Now, we send the custom characters to the LCD
character RAM by using a FOR-NEXT loop and the
LOOKUP command. The FOR-NEXT loop counts from 0 to
63, for a total of 64 loops, and it defaults to stepping one
count per loop. The variable x stores the present loop count
value. The LOOKUP command then takes the value of
x and jumps that many places, reads the byte value, and
stores it in the “char” variable. For example, lets assume
x = 5 or the sixth time through the loop since the count
starts at zero. The value of “char” will equal $1C, since it is
the sixth value listed.
for x = 0 to 63
After the code above executes, the custom characters
are now in the LCD character-generator memory. The
program can now call them to create the large characters
on the LCD. The “main” label starts the central program
loop. In the section below main, we use the LCDWRITE
command to display a description of what this program will
do, as shown in Figure 2. We display “Large Digits Using”
by using the LCDWRITE command.
‘ *** Initial screen with program description ***
lcdwrite rspin\epin,outc,[clear,home,scrram,”Large Digits
lcdwrite rspin\epin,outc,[scrram + $40]
This next section will call up the custom characters just
created, one at a time, using a FOR-NEXT loop, and will
display them using the LCDWRITE command. The variable
x holds a value from 0 to 7. LCDWRITE directs the LCD to
display characters 0 through 7. See how easy it is to display
custom characters, once they are created?
16 September 2007
for x = 0 to 7
We finish this block of code by displaying “Custom
Characters” and “Demo in three seconds” to the display
lines 3 and 4. SCRRAM +$14 is the beginning of line 3, and
SCRRAM +$54 is the beginning of line 4.
lcdwrite rspin\epin, outc,[scrram + $14, |
lcdwrite rspin\epin, outc,[scrram + $54, |
“““Demo in 3 seconds”]
Finally, we pause three seconds so you can read the
display and then move on to the next section.
From here, the program creates the custom large characters using the custom 5x8 characters stored in CGRAM. I’ll
just describe the digit 1 shown in Figure 3, but all the other
large character sections below operate in the same manner.
The #1 character is created by placing custom
characters 1 and 6 on line 1, character 6 on line 2,
character 6 on line 3, and characters 5, 6, and 5 on line 4.
We then pause one second, so the digit can be read. The
SCRRAM is offset with values that center the 1 on the LCD.
‘ *** “1” character
The rest of the large digits (0 through F) are created in
a similar fashion. Each is displayed, and then a final message
is displayed. The final section of code displays, “Just
imagine what you can do.”
‘ *** Final message from program before looping back to
the top ***
”””Just imagine what”,scrram+$40,”you can do!”]
With this custom character method, you can create just
about anything on an LCD screen.
The projects that can result from this are endless. Just
remember that nothing stops you from redefining the
custom characters in the middle of the program. Let’s say
you want to display large characters, initially, and then later
in the program want to create an animation using different
After completing the large custom number characters,
clear the LCD screen and then load new custom characters