2x40 LCD
Newzed
Posts: 2,503
I have a 2x40 LCD I'm having a few problems with.· Does any one know the starting cursor address for Lines 1 and 2.
Thanks
Sid
Thanks
Sid
Comments
I would use $80 as the starting address.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
·· If you're talking about the LCDs I think you are, then the start address is $00 and the second line is $40.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
init:
addr·= 128
start:
debug dec ? addr, cr
gosub LCDCommand
char = "*"
gosub LCDWrite
pause 1000
addr = addr + 1
debug "Press any key to continue", cr
debugin com
goto start
Sid
addr··· VAR··· Byte
char··· VAR··· Byte
com···· VAR··· Byte
Reset:
· addr = $80
Main:
· DO
··· char = LcdCls························ ' clear LCD·
··· GOSUB LcdCommand
··· PAUSE 2······························ ' do not remove -- LCD needs time
··· char = addr
··· GOSUB LcdCommand····················· ' position cursor
··· char = "*"
··· GOSUB LcdWrite······················· ' print *
··· DEBUG HOME, "Addr = ", IHEX2 addr···· ' display current address
··· addr = addr + 1·······················' point to next·
··· DEBUGIN com·························· ' get key
··LOOP UNTIL (com = "x")················· ' do again unless "x" pressed
· END
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Sid
·· I don't know what to tell you...Using the BS2p, I was able to address them the same as any other 2X40 using the standard Hitachi addresses of $00 for the first line, and $40 for the second line.· Those units were tested.· Although 2 or 3 required negative bias on the Vee line.· So I guess my question is, are you getting anything on the display at all?· If not, that's probably what's wrong.· You'll probably need between -0.5 and -1.5V on Vee.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Sid
Sid
Sid
·· I've never seen it done that way, but maybe...The problem is you won't know how much voltage until you start going negative from 0.· You don't want to go too far.· You should be sure you have the correct datasheet for the module.· If you can't find one, better safe than sorry.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·· I realized my post above about LCD addresses might cause some confusion so I wanted to address that right now.· The addresses for the LCD are formed by assigning the 7-bit address ($00-$7F) to the command byte for writing data to the DDRAM.· Because of the way this is done on the BASIC Stamp the BUSY Flag isn't used by most of the code, and therefore we ignore BIT7.· During the writes to DDRAM BIT7 is always 1, so in that sense the actual value of the command sent will be from $80-FF.· Sorry for any confusion.
·· The same effect happens when addressing the RAM on the DS1302 RTC.· The actual byte sent will vary some depending on the actual address, which is only 5 bits.· But that address is encoded into the command byte for a read or write, meaning certain bits are alwats set.· I hope this explains things a little better.· If you don't understand the inner workings of the LCD, definately use Jon's code.· That stuff happens in the background and you don't have to worry about it.
·· My main thing was that when you look at LCD address maps, this is why they say $00 for the starting address, and why line 2 on 2 line displays is usually $40.· On 4 line displays things get a little weird because the lines are not addressed in order.· But rather line 1 is usually $00, line 2 is usually $40, line 3 is usually $20 and line 4 is usually $60.· On 4 X 40 line displays this gets even more complicated since there are actually 2 controllers and 2 enable lines.
NOTE:· The above information applies to HD44780 or compatible modules.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 6/2/2005 4:53:17 PM GMT
Sid
·· Yes, you can try that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
With the 2x20 I got Line 1 = 128, Line 2 = 168(addr changed but * did not advance), Line 2 = 192.· My program uses 128 and 192.· Changed 192 to 168 and program still worked perfectly.· Strange
I then tried it out with the 4x20 and got Line 1 = 128, Line 3 = 148, Line 2 = 192, Line 4 = 212.· These are the values I'm using in my current program.
Tried it with the 2x40 - nothing.
Thanks for the help - I'm sure I'll be using that program·many times·in the future.
Sid
LcdLine1······· CON···· $80···················· ' DDRAM address of line 1
LcdLine2······· CON···· $C0···················· ' DDRAM address of line 2
... in my LCD programs for the last 10 years ($80 = 128, $C0 = 192).· Most character LCD driver chips, even the off-brands, comply with the Hitachi HD44780 spec (or come really close).
I don't know how to explain the problems you're having with the 2x40; you don't see those around much, perhaps it's an odd duck.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Cursor addresses are $80 and $C0.
Sid