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 />

Listing 8-4 (page 1 of 2). Initializes a 2-line LCD module and displays a<br />

message on each line.<br />

10 REM address of 8255, Port A<br />

20 A=0FC00H<br />

30 REM address of 8255, Port C<br />

40 C=A+2<br />

50 REM address of 8255, Control port<br />

60 X=A+3<br />

70 REM Control word for Enable (PC.5)<br />

80 E=0AH<br />

90 REM Control word for RW (PC.6)<br />

100 RW=0CH<br />

110 REM Control word for RS (PC.4)<br />

120 RS=8<br />

130 REM Initialize LCD module<br />

140 REM initial values<br />

150 XBY(X)=80H: REM Ports A,B,&C are outputs<br />

160 XBY(X)=E : REM E=1<br />

170 XBY(X)=RW : REM RW=1<br />

180 XBY(X)=RS : REM RS=1<br />

190 REM function set: 8-bit interface, 3 times<br />

200 REM toggle E after each instruction<br />

210 XBY(A)=30H<br />

220 XBY(X)=E+1:XBY(X)=E<br />

230 XBY(A)=30H<br />

240 XBY(X)=E+1:XBY(X)=E<br />

250 XBY(A)=30H<br />

260 XBY(X)=E+1:XBY(X)=E<br />

270 REM function set to match module<br />

280 XBY(A)=38H<br />

290 XBY(X)=E+1:XBY(X)=E<br />

300 REM display on<br />

310 XBY(A)=0CH<br />

320 XBY(X)=E+1:XBY(X)=E<br />

330 REM clear display<br />

340 XBY(A)=01H<br />

350 XBY(X)=E+1:XBY(X)=E<br />

360 REM entry mode set<br />

370 XBY(A)=06H<br />

380 XBY(X)=E+1:XBY(X)=E<br />

146 <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!