|
AN507 |
Product: Domino 1 and 2 |
|
Added LCD Control |
Date: 3/12/99 |
Introduction: This application note demonstrates how to access some of the additional features of the Hitachi PN LM044L 4X20 LCD. | |
Background: While the Domino modules have built-in firmware to control an LCD through the I2C bus, they don’t give you access to certain LCD features. The additional features include: · Clear the LCD’s screen. · Turn the LCD on and off. · Turn the cursor on and off. · Make the cursor blink. |
|
How it works: This program demonstrates how to access some of the
Hitachi PN LM044L 4X20 LCD features using the I2C Byte transfer
function. Using a Phillips/Signetics PCF8574 I2C I/O expander
with the slave address 01000010 we can communicate to a parallel LCD
screen serially by sending it nibbles of information. The I2C
I/O expander only has enough I/O to control the LCD screen in nibble mode.
This program allows you to enter a string and display it on the LCD, turn
the display and the cursor on and off, make the cursor blink, and clear
the entire screen. |
|
Program Listing:
10 REM ********************************************************** 20 REM *** This program demonstrates how to use some of the 30 REM *** features on the Hitachi PN LM044L 4X20 LCD. Please 40 REM *** remember you’re not talking directly to the LCD you are 50 REM *** talking to the PCF8574 chip. 60 REM *********************************************************** 70 REM *** Setting MTOP so we can use the U01 command. 80 MTOP=03FFFH 85 STRING 82,80 90 REM *** Initialize the LCD screen using Domino Utilities. 100 REM *** Using this call sets the LCD into nibble mode. 110 CALL 0F030H 120 ?"Choose a function." 130 ?"1 - Clear the LCD screen." 140 ?"2 - Turn the LCD screen off." 150 ?"3 - Turn the LCD screen on." 160 ?"4 - Turn the cursor off." 170 ?"5 - Turn the cursor on." 180 ?"6 - Have the cursor blink." 190 ?"7 - Have the cursor not blink." 200 ?"8 - Print characters to the screen." 210 INPUT Z 220 IF Z=1 THEN GOTO 320 230 IF Z=2 THEN GOTO 350 240 IF Z=3 THEN GOTO 410 250 IF Z=4 THEN GOTO 410 260 IF Z=5 THEN GOTO 380 270 IF Z=6 THEN GOTO 440 280 IF Z=7 THEN GOTO 470 290 IF Z=8 THEN GOTO 500 ELSE GOTO 120 300 REM *** Hex values for nibble's 1 and 2 310 REM *** Values for clearing the screen 320 A=20H:B=21H 325 GOSUB 10130 330 GOTO 120 340 REM *** Values for turning the screen off 350 A=20H:B=28H 355 GOSUB 10130 360 GOTO 120 370 REM *** Values to turn the cursor on 380 A=20H:B=2EH 385 GOSUB 10130 390 GOTO 120 400 REM *** Values to turn the cursor off and to turn the display on. 410 A=20H:B=2CH 415 GOSUB 10130 420 GOTO 120 430 REM *** Values to make the cursor blink 440 A=20H:B=2FH 445 GOSUB 10130 450 GOTO 120 460 REM *** Values to make the cursor not blink 470 A=20H:B=2EH 475 GOSUB 10130 480 GOTO 120 490 REM *** Routine to print to the LCD. 500 INPUT"Please type what you want to display on the LCD."$(0) 510 REM *** Domino Utility call to display $(0) on the LCD. 520 CALL 0F040H 530 GOTO 120 10000 REM *** Subroutine for writing 2 nibbles to the LCD. 10100 REM *** Push the first nibble to the LCD 10110 REM *** 42H = the slaves address. 100H = upper byte 10120 REM *** A = the value to write to the LCD. 10130 PUSH 42H*100H+A 10140 REM*** Domino Utility call for sending an I2C byte. 10150 CALL 0F120H 10160 POP C 10170 REM *** Low the E pin on the LCD. This tells the LCD it is going to receive the first nibble 10180 REM *** To eliminate steps performed by the processor we can 10190 REM *** multiply 42H and 100H for the processor. 10200 REM *** 4200H = The slaves address and the value it takes to move 10210 REM *** it to the upper byte. 0H = the value sent to low the E pin 10220 REM *** on the LCD display. 10230 PUSH 4200H+0H 10240 REM *** Domino Utility call for sending an I2C byte. 10250 CALL 0F120H 10260 POP C 10270 REM *** Push the second nibble to the LCD 10280 REM *** 4200H = The slaves address and the value it takes to move it 10290 REM *** to the upper byte. B = the value sent to the slave depending 10300 REM *** on the desired function. 10310 REM *** Clear the screen = 21H 10320 REM *** Turn the screen off = 28H 10330 REM *** Turn the screen on = 2CH 10340 REM *** Turn the cursor on = 2EH 10350 REM *** Turn the cursor off = 2CH 10360 REM *** Blinking cursor = 2FH 10370 REM *** Stop blinking cursor = 2EH 10380 PUSH 4200H+B 10390 CALL 0F120H 10400 POP C 10410 REM *** Low the E pin on the LCD to tell it that it is about 10415 REM *** to receive a second nibble. 10420 PUSH 42H*100H+0H 10430 CALL 0F120H 10440 POP C 10450 RETURN
|