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

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

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

Chapter 8<br />

Table 8-3. Initialization procedure for LCD modules using HD44780<br />

controller.<br />

Power on<br />

Wait 15 milliseconds after V+ = 4.5V<br />

Function set = 30h<br />

Wait 4.1 milliseconds<br />

Function set = 30h<br />

Wait 100 microseconds<br />

Function set = 30h<br />

Function set to match display module<br />

Display on<br />

Display clear<br />

Entry mode set<br />

set I equal to the instruction and call subroutine 900, which clears RS, writes the instruction<br />

to the display, and toggles E.<br />

Using the example program as a model, you can experiment with your own messages by<br />

adapting the code in lines 400-530.<br />

Listing 8-5 is another test program that displays a prompt on the host’s screen and then<br />

displays the character you type at the keyboard both on the host’s screen and on the LCD<br />

module. To use this program, you must add lines 10 through 380 of Listing 8-4 to initialize<br />

the module and variables.<br />

<strong>The</strong> 4-bit Interface<br />

<strong>The</strong> HD44780’s 4-bit data interface can be convenient if you don’t have a lot of port bits to<br />

spare. <strong>The</strong> minimum interface requires just 6 outputs, to D4-D7, RS, and E. <strong>The</strong> drawback is<br />

that the 4-bit interface is slower in operation and more complicated to program.<br />

To send an instruction using a 4-bit interface, you send half at a time over D4-D7, along with<br />

the appropriate RS and R/W signals. D0-D3 are unused. For example, with an 8-bit interface,<br />

writing Z (5Ah) to the display requires the following operations:<br />

clear R/W<br />

set RS<br />

write 5Ah to D0-D7<br />

bring E high, then low<br />

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

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

Saved successfully!

Ooh no, something went wrong!