04.03.2013 Views

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Commands<br />

Custom Characters<br />

Most HD44780 controllers provide room for 8 user defi nable characters, they are ASCII values 0 to<br />

7. The programmable characters are 5x8 pixels. There are 8 bytes for each custom character. The<br />

bytes are arranged in a grid to defi ne the new character. The custom characters can be used to make<br />

sprites that can then be used to form larger characters that are made up of multiple locations and<br />

spread across more than one display line. The fi rst 3 bits are ignored (7-5), only bits 4-0 are used to<br />

defi ne the character. An on pixel is expressed with a 1 and off is 0.<br />

Bits -> 4 3 2 1 0 Binary Hex Decimal<br />

Byte 0 00000000 00 00<br />

Byte 1 00001010 0A 10<br />

Byte 2 00001010 0A 10<br />

Byte 3 00001010 0A 10<br />

Byte 4 00000000 00 00<br />

Byte 5 00010001 11 17<br />

Byte 6 00001110 0E 14<br />

Byte 7 00000000 00 00<br />

Example<br />

To write and display the custom characters shown above, you would use the LCDWRITE command<br />

with the CGRAM function. The following code snippet will write and display the custom character<br />

shown above on a 2x16 LCD display. Connect LCD using the schematics shown for LCDINIT.<br />

lcdinit p0\p1\p7\p6\p5\p4<br />

lcdwrite p0\p1\p7\p6\p5\p4,[cgram+0,0x00,0x0A,0x0A,0x0A,0x00,0x11,0x0E,0x00,scrram+0]<br />

Using our newly created custom character, the below sample program will clear the screen and<br />

starting from the home position print “Hello Word!”.<br />

lcdinit p0\p1\p7\p6\p5\p4<br />

;create custom character<br />

lcdwrite p0\p1\p7\p6\p5\p4,[cgram+0,0x00,0x0A,0x0A,0x0A,0x00,0x11,0x0E,0x00,scrr<br />

am+0]<br />

;clear screen, home cursor, print “Hello World!” and custom character<br />

lcdwrite p0\p1\p7\p6\p5\p4,[lcdclear,lcdhome,”Hello World! “,0]<br />

141

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!