18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Each character in the CG ROM and CG RAM has an 8-bit address, or character code.<br />

Conveniently, the codes for the upper and lower-case Roman alphabet and common<br />

punctuation are same as the ASCII codes for those characters (21h through 7Dh). For<br />

example, the pattern for A is stored at address 41h, B is stored at at 42h, and so on.<br />

An 8-bit instruction register (IR) stores instruction codes and addresses, and an 8-bit data<br />

register (DR) stores character codes. When you read or write to the chip, you must select<br />

the appropriate register.<br />

<strong>The</strong> DD RAM stores up to eighty 8-bit character codes. Each character position on the<br />

display corresponds to an address in the DD RAM, and the character codes stored in the DD<br />

RAM determine what is displayed at each position.<br />

On power up, on a 2-line display, the leftmost position on the top line has an address of 0,<br />

with the rest of the positions in the line addressed in sequence. <strong>The</strong> second line begins at<br />

40h, even if the top line has fewer than 40h positions.<br />

<strong>The</strong> instructions allow you to configure a module so that the DD RAM’s address increments<br />

each time a character is written to the display. This way, the characters automatically appear<br />

in sequence on the display without your having to specify an address each time.<br />

Because the second line begins at 40h, however, the display will not wrap around automatically<br />

to this line. For example, on a 2-line, 16-position display, line 1 ends at 0Fh and line<br />

2 begins at 40h. To move from the rightmost position of line 1 to the leftmost position of<br />

line 2, you have to change the address counter to 40h. In addition, some displays with a<br />

single physical line of characters have two logical lines. In a 16-character display of this<br />

type, the first 8 characters are addressed from 0 to 7, and the second 8 are addressed from<br />

40h to 47h. With this type of display, you must set the address counter to 40h before you<br />

write to the second half of the line.<br />

On a small display where all 80 bytes of DD RAM aren’t needed, you can use the spare DD<br />

RAM as general-purpose RAM.<br />

Reading and Writing<br />

Writing to the LCD module involves the following steps:<br />

Bring RS high to write data, or low to write an instruction.<br />

Bring R/W low.<br />

Bring D0-D7 to their desired states.<br />

Wait at least 140 nanoseconds.<br />

Bring E high for at least 450 nanoseconds.<br />

Bring E low.<br />

Displays<br />

<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 143

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

Saved successfully!

Ooh no, something went wrong!