HD44780 Hitachi 1x16 LCD
Archiver
Posts: 46,084
Hi all,
I am trying to wake up a HD44780 LCD, 1 line of 16 characters
connected to a BS2 sx.
The module is a Powertip 1601, for wich very few information
can be found on the net. The technical sheet is not informative
at all.
I wrote the program hereunder and the only result that I got
was to black the first 8 characters of the display.
Note that the debug instructions are only for verification.
Can anybody help?
Many thanks in advance
ECO
'BS2sx to HD44780 LCD, using 4+2 pins
pin0 var OUTL.bit0·'LCD bit 4
pin1 var OUTL.bit1·'LCD bit 5
pin2 var OUTL.bit2·'LCD bit 6
pin3 var OUTL.bit3·'LCD bit 7
rsel var OUTL.bit4·'Select, 0=instr. 1=char
enab var OUTL.bit5·'LCD enable = 1
·················· 'R/W = Vss
char var byte··· ··'character to write
flag var byte···· ·'bit4 0=instr. 1=char.
init:
DIRL = %00111111···'6 LSB = outputs
pause 40
flag = %00000000···'instruction flag
OUTL = %00000011·· 'Initialize by
pulsout enab,60··· 'sending this pattern
pause 6······ ···· '4 times for 40 µS
pulsout enab,60··· 'separated with 5 mS
pause 6
pulsout enab,60
pause 6
pulsout enab,60
pause 6
OUTL = %00100100·· 'Function set:4bits,1 line,5*10 dots
pulsout enab,60··· 'send this pattern
pause 6
pulsout enab,60· ··'3 times for 40 µS
pause 6
pulsout enab,60
pause 6
char = %00000100
gosub writ
char = %00000110· ·'set increment,no shift
gosub writ
char = %00000001·· 'clear the display
gosub writ
flag = %00010000 ··'character flag
loop:
serin 16,240,[noparse][[/noparse]char]·'get a character from PC
debug HEX char
gosub writ··········'write it on LCD
goto loop···········'redo
writ:
OUTL = flag|char.highnib 'put high nibble in output
debug " ",HEX OUTL
pulsout enab,60····· ··· 'enable for 40µS
pause 6
OUTL = flag|char.lownib· 'put low nibble in output
debug " ",HEX OUTL
pulsout enab,60··········'enable for 40µS
return
I am trying to wake up a HD44780 LCD, 1 line of 16 characters
connected to a BS2 sx.
The module is a Powertip 1601, for wich very few information
can be found on the net. The technical sheet is not informative
at all.
I wrote the program hereunder and the only result that I got
was to black the first 8 characters of the display.
Note that the debug instructions are only for verification.
Can anybody help?
Many thanks in advance
ECO
'BS2sx to HD44780 LCD, using 4+2 pins
pin0 var OUTL.bit0·'LCD bit 4
pin1 var OUTL.bit1·'LCD bit 5
pin2 var OUTL.bit2·'LCD bit 6
pin3 var OUTL.bit3·'LCD bit 7
rsel var OUTL.bit4·'Select, 0=instr. 1=char
enab var OUTL.bit5·'LCD enable = 1
·················· 'R/W = Vss
char var byte··· ··'character to write
flag var byte···· ·'bit4 0=instr. 1=char.
init:
DIRL = %00111111···'6 LSB = outputs
pause 40
flag = %00000000···'instruction flag
OUTL = %00000011·· 'Initialize by
pulsout enab,60··· 'sending this pattern
pause 6······ ···· '4 times for 40 µS
pulsout enab,60··· 'separated with 5 mS
pause 6
pulsout enab,60
pause 6
pulsout enab,60
pause 6
OUTL = %00100100·· 'Function set:4bits,1 line,5*10 dots
pulsout enab,60··· 'send this pattern
pause 6
pulsout enab,60· ··'3 times for 40 µS
pause 6
pulsout enab,60
pause 6
char = %00000100
gosub writ
char = %00000110· ·'set increment,no shift
gosub writ
char = %00000001·· 'clear the display
gosub writ
flag = %00010000 ··'character flag
loop:
serin 16,240,[noparse][[/noparse]char]·'get a character from PC
debug HEX char
gosub writ··········'write it on LCD
goto loop···········'redo
writ:
OUTL = flag|char.highnib 'put high nibble in output
debug " ",HEX OUTL
pulsout enab,60····· ··· 'enable for 40µS
pause 6
OUTL = flag|char.lownib· 'put low nibble in output
debug " ",HEX OUTL
pulsout enab,60··········'enable for 40µS
return
Comments
See the code below corrected and streamlined.
Thanks to your advice it is now 90% OK.
The only remaining problem, for wich I don't find answer in the documents,
is that it writes only 8 characters although the module is clearly made for 16
characters on one line. I miss perhaps a command?
Thanks for your help (If you have time!)
Regards,
ECO
'BS2sx to HD44780 1x16 LCD, using 4+2 pins
'BS2sx· to·LCD
'bit0····· pin11 = bit4
'bit1····· pin12 = bit5
'bit2····· pin13 = bit6
'bit3····· pin14 = bit7
'bit4····· pin04 = select
'bit5····· pin06 = enable
'········· pin05 = R/W = Vss
'····· ··· pin01 = Vss
'····· ··· pin02 = Vdd
'····· ··· pin03 = contrast
char var byte··'character to write
flag var byte··'bit4 0=instr. 1=char.
init:
DIRL = %00111111··'6 LSB = outputs
pause 500
flag = %00000000··'instruction flag
OUTL = %000011····'Initialize by
pulsout 5,50···· ·'sending this pattern
pause 5······ ··· '3 times for 40 µS
pulsout 5,50
pulsout 5,50
OUTL = %0010····· 'Function set:4bits
pulsout 5,50··
char = %00001101··'disp on,cursor off,blink on
gosub writ
char = %00000110··'set increment,no shift
gosub writ
clear:
flag = %00000000··'instruction flag
char = %00000001··'clear the display
gosub writ
char = %00000010··'cursor home
gosub writ
flag = %00010000··'character flag
loop:
serin 16,240,[noparse][[/noparse]char]···· 'get a character from PC
if char=$0D then clear··'if CR then clear screen
gosub writ··············'write it on LCD
goto loop··· ··· ··· ···'redo
writ:
OUTL = flag|char.highnib··'put high nibble in output
pulsout 5,50··· ··· ··· ··'enable for 40µS
OUTL = flag|char.lownib···'put low nibble in output
pulsout 5,50····· ··· ··· 'enable for 40µS
return
Original Message
From: "S Parkis" <parkiss@earthlink.net>
To: "ECO" <ecourt@belgacom.net>; <basicstamps@yahoogroups.com>
Sent: dimanche 27 mai 2001 00:32
Subject: Re: [noparse][[/noparse]basicstamps] HD44780 Hitachi 1x16 LCD boundary="----=_NextP
> ECO-
>
> There's a problem in the way you're using PULSOUT
>
> Regards,
>
> Steve
Many 1x16 LCDs are actually physically similar to a 2x8 LCD screen
that has the second row moved up into the first line (after character
8). Even though there are 16 characters on the first line, you need
to treat characters 9-16 as if they were the first 8 characters of
the second line.
I hope this helps! Good luck with your project!
--Jeff Wallace
* Add a RTC, 256k EEPROM and an I2C bus to your BS2
http://www.high-techgarage.com/products/timekeeper.php
--- In basicstamps@y..., "ECO" <ecourt@b...> wrote:
> Steve
> See the code below corrected and streamlined.
> Thanks to your advice it is now 90% OK.
> The only remaining problem, for wich I don't find answer in the
documents,
> is that it writes only 8 characters although the module is clearly
made for 16
> characters on one line. I miss perhaps a command?
> Thanks for your help (If you have time!)
> Regards,
> ECO
>
> 'BS2sx to HD44780 1x16 LCD, using 4+2 pins
>
> 'BS2sx to LCD
> 'bit0 pin11 = bit4
> 'bit1 pin12 = bit5
> 'bit2 pin13 = bit6
> 'bit3 pin14 = bit7
> 'bit4 pin04 = select
> 'bit5 pin06 = enable
> ' pin05 = R/W = Vss
> ' pin01 = Vss
> ' pin02 = Vdd
> ' pin03 = contrast
>
> char var byte 'character to write
> flag var byte 'bit4 0=instr. 1=char.
>
> init:
> DIRL = %00111111 '6 LSB = outputs
> pause 500
> flag = %00000000 'instruction flag
> OUTL = %000011 'Initialize by
> pulsout 5,50 'sending this pattern
> pause 5 '3 times for 40 µS
> pulsout 5,50
> pulsout 5,50
> OUTL = %0010 'Function set:4bits
> pulsout 5,50
> char = %00001101 'disp on,cursor off,blink on
> gosub writ
> char = %00000110 'set increment,no shift
> gosub writ
> clear:
> flag = %00000000 'instruction flag
> char = %00000001 'clear the display
> gosub writ
> char = %00000010 'cursor home
> gosub writ
> flag = %00010000 'character flag
>
> loop:
> serin 16,240,[noparse][[/noparse]char] 'get a character from PC
> if char=$0D then clear 'if CR then clear screen
> gosub writ 'write it on LCD
> goto loop 'redo
>
> writ:
> OUTL = flag|char.highnib 'put high nibble in output
> pulsout 5,50 'enable for 40µS
> OUTL = flag|char.lownib 'put low nibble in output
> pulsout 5,50 'enable for 40µS
> return
>
>
>
Original Message
> From: "S Parkis" <parkiss@e...>
> To: "ECO" <ecourt@b...>; <basicstamps@y...>
> Sent: dimanche 27 mai 2001 00:32
> Subject: Re: [noparse][[/noparse]basicstamps] HD44780 Hitachi 1x16 LCD boundary="----
=_NextP
>
>
> > ECO-
> >
> > There's a problem in the way you're using PULSOUT
> >
> > Regards,
> >
> > Steve
ecourt@belgacom.net writes:
is that it writes only 8 characters although the module is clearly made for
16
characters on one line.
Your LCD is actually a 2x8 LCD, physically configured as a single-line
display. ·This are a really big headache. ·In order to write the the other
half of the display, you need to configure the LCD in multi-line mode and
then write to the second line.
-- Jon Williams
-- Dallas, TX[/font]
Many thanks for your help.
For everybody:
Take note of this code, to avoid 8 hours of frustration.
Regards
ECO
'BS2sx to HD44780 1x16 LCD, using 4+2 pins
'BS2sx to··· LCD
'bit0··· ··· pin11 = bit4
'bit1··· ··· pin12 = bit5
'bit2··· ··· pin13 = bit6
'bit3··· ··· pin14 = bit7
'bit4··· ··· pin04 = select
'bit5··· ··· pin06 = enable
'··· ··· ··· pin05 = R/W = Vss
'··· ··· ··· pin01 = Vss
'··· ··· ··· pin02 = Vdd
'··· ··· ··· pin03 = contrast
char var byte··· 'character to write
flag var byte··· 'bit4 0=instr. 1=char.
indx var nib
init:
DIRL = %00111111··· '6 LSB = outputs
pause 500
OUTL = %000011······ 'Initialize by
pulsout 5,50··· ··· 'sending this pattern
pause 5··· ··· ···· '3 times for 40 µS
pulsout 5,50
pulsout 5,50
OUTL = %0010··· ··· 'Function set: 4bits
pulsout 5,50
char = %00101000··· 'set for 2 lines or 16 characters
gosub comm
char = %00001101··· 'disp on, cursor off, blink on
gosub comm
char = %00000110··· 'set increment,no shift
gosub comm
clear:
char = %00000001··· 'clear the display
gosub comm
loop:
char = %00000010··· 'cursor home 1st block
gosub comm
indx = 0
for indx = 0 to 7
serin 16,240,[noparse][[/noparse]char]··· 'get a character from PC
if char=$0D then clear 'if CR then clear screen
gosub writ··· ··· ··· 'write it on LCD
next
char = %11000000······ 'cursor home 2nd block
gosub comm
indx = 0
for indx = 0 to 7
serin 16,240,[noparse][[/noparse]char]··· 'get a character from PC
if char=$0D then clear 'if CR then clear screen
gosub writ··· ··· ··· 'write it on LCD
next
goto loop··· ··· ···· 'redo
comm:
flag = %00000000······ 'instruction flag
writ:
OUTL = flag|char.highnib 'put high nibble in output
pulsout 5,50 ··· ··· ··· 'enable for 40µS
OUTL = flag|char.lownib· 'put low nibble in output
pulsout 5,50··· ··· ··· 'enable for 40µS
flag = %00010000··· ··· 'character flag
return