HD44780 LCD Display Module
Archiver
Posts: 46,084
Nathan-
The following works pretty good. Modify the pin numbers in the
constants to suit your layout, but the code assumes I/O 12 is
connected to LCD data 4...I/O 15 connected to LCD data 7 (allowing
use of OUTD). If you power your LCD directly you can do away with
the lcdpower pin and associated code (your Stamp can provide plenty
of power from one of its pins to run most modules).
lcd_rw CON 5
lcd_rs CON 6
lcd_en CON 7
lcdpower CON 8
rom_addr VAR WORD
rom_data VAR BYTE
test_msg DATA "Test",0
GOSUB initLCD
' move cursor to LCD address 82
OUTD = $80 + 82 >> 4: GOSUB command
OUTD = $80 + 82: GOSUB command
' dislplay 'X'
OUTD = "X" >> 4: PULSOUT lcd_en,1
OUTD = "X": PULSOUT lcd_en,1
' show message in ROM
GOSUB clearLCD
rom_addr = test_msg
dis_loop:
READ rom_addr,rom_data
IF rom_data = 0 THEN quit
OUTD = rom_data >> 4: PULSOUT lcd_en,1
OUTD = rom_data: PULSOUT lcd_en,1
rom_addr = rom_addr+1
GOTO dis_loop
quit:
STOP
initLCD:
HIGH lcdpower: PAUSE 100 'apply power, let lcd init
OUTD = %0011 'send init sequence
PULSOUT lcd_en,1: PAUSE 2
PULSOUT lcd_en,1: PAUSE 2
PULSOUT lcd_en,1: PAUSE 2
OUTD = %0010 : GOSUB command '4-bit mode
OUTD = %0010 : GOSUB command '2 lines, 5x7
OUTD = %1000 : GOSUB command
OUTD = %0000 : GOSUB command 'display on, invisible cursor
OUTD = %1100 : GOSUB command
OUTD = %0000 : GOSUB command 'cursor adv right, shift not
OUTD = %0110 : GOSUB command
clearLCD:
OUTD = %0000 : GOSUB command 'clear screen
OUTD = %0001 : GOSUB command
RETURN
command:
LOW lcd_rs: PAUSE 2
PULSOUT lcd_en,1: PAUSE 2
HIGH lcd_rs: PAUSE 2
RETURN
On 20 Aug 00 at 22:46, Nathan Keir wrote:
> ...I'm looking for is BS2 code for the first Basic Stamp 1
> application note. (It explains how to run the LCD module in 4 bit
> mode from a BS1)...
The following works pretty good. Modify the pin numbers in the
constants to suit your layout, but the code assumes I/O 12 is
connected to LCD data 4...I/O 15 connected to LCD data 7 (allowing
use of OUTD). If you power your LCD directly you can do away with
the lcdpower pin and associated code (your Stamp can provide plenty
of power from one of its pins to run most modules).
lcd_rw CON 5
lcd_rs CON 6
lcd_en CON 7
lcdpower CON 8
rom_addr VAR WORD
rom_data VAR BYTE
test_msg DATA "Test",0
GOSUB initLCD
' move cursor to LCD address 82
OUTD = $80 + 82 >> 4: GOSUB command
OUTD = $80 + 82: GOSUB command
' dislplay 'X'
OUTD = "X" >> 4: PULSOUT lcd_en,1
OUTD = "X": PULSOUT lcd_en,1
' show message in ROM
GOSUB clearLCD
rom_addr = test_msg
dis_loop:
READ rom_addr,rom_data
IF rom_data = 0 THEN quit
OUTD = rom_data >> 4: PULSOUT lcd_en,1
OUTD = rom_data: PULSOUT lcd_en,1
rom_addr = rom_addr+1
GOTO dis_loop
quit:
STOP
initLCD:
HIGH lcdpower: PAUSE 100 'apply power, let lcd init
OUTD = %0011 'send init sequence
PULSOUT lcd_en,1: PAUSE 2
PULSOUT lcd_en,1: PAUSE 2
PULSOUT lcd_en,1: PAUSE 2
OUTD = %0010 : GOSUB command '4-bit mode
OUTD = %0010 : GOSUB command '2 lines, 5x7
OUTD = %1000 : GOSUB command
OUTD = %0000 : GOSUB command 'display on, invisible cursor
OUTD = %1100 : GOSUB command
OUTD = %0000 : GOSUB command 'cursor adv right, shift not
OUTD = %0110 : GOSUB command
clearLCD:
OUTD = %0000 : GOSUB command 'clear screen
OUTD = %0001 : GOSUB command
RETURN
command:
LOW lcd_rs: PAUSE 2
PULSOUT lcd_en,1: PAUSE 2
HIGH lcd_rs: PAUSE 2
RETURN
On 20 Aug 00 at 22:46, Nathan Keir wrote:
> ...I'm looking for is BS2 code for the first Basic Stamp 1
> application note. (It explains how to run the LCD module in 4 bit
> mode from a BS1)...
Comments
Just joined this mailing list, and I'm looking for some source code. I've
got myself an HD44780 display and a BS2.
What I'm looking for is BS2 code for the first Basic Stamp 1 application
note. (It explains how to run the LCD module in 4 bit mode from a BS1). Of
course I could convert the code myself but I figured someone else out there
must've already done this...
Cya,
Kermitt