Posted: Wed Oct 14, 2009 8:28 pm Post subject: LCD MDLS40466
Peace for All
I m using the following code as it is on MDLS40466 40*4 LCD in proteus but the lines 1,2,3,4 are not aligned means the Locate 2,1 or 3,1 Have different positions in their respective lines as it is supposed to be according to the 'Locate' instruction.
kindly bail me out of this.
Regards.
' Luciano 7/24/06
'
' How to use the Bascom AVR custom LCD library "LCD4E2".
'
' For a HD44780 based LCD with 4 lines of 40 characters. (160 characters).
' The LCD module is used in 4 bit mode with two enable lines.
' (A 40 * 4 LCD module has two HD44780 controllers, therefore two enable lines).
'
' Hardware connections:
' LCD / AVR
' =============
' Rs = PortB.0
' RW = GND (Connect the LCD pin R/W to ground)
' E = PortB.2
' E2 = PortB.3
' Db0 = (This LCD pin is not connected)
' Db1 = (This LCD pin is not connected)
' Db2 = (This LCD pin is not connected)
' Db3 = (This LCD pin is not connected)
' Db4 = PortB.4
' Db5 = PortB.5
' Db6 = PortB.6
' Db7 = PortB.7
'
' When you use the Bascom LIB lcd4e2.lib "Config Lcdpin" is not used.
' The used port and pins are difined in the source code of lcd4e2.lib.
' With lcd4e2.lib all the used pins MUST be on the SAME PORT.
' In the source code of lcd4e2.lib you can change the used port.
' Example: You can change from PortB to PortD.
' With the demo version of Bascom AVR you only get the compiled
' version of the lib.(lcd4e2.lbx) and therefore you can only use
' the PortB as it is described in this example.
'
' (Before you change the source code in the file lcd4e2.lib make a copy
' of the original file so you can go back with the changes if necessary).
'
'
$regfile = "m32def.dat"
$crystal = 16000000
$hwstack = 32
$swstack = 16
$framesize = 32
' this is the custom LCD lib
$lib "Lcd4e2.lib" ' demo version users please use : $lib "Lcd4e2.lbx"
Dim ___lcde As Byte
Waitms 100 'Wait for LCD power-up
'--------------------------------------------------
' clear line 1 and line 2 and set cursor off
___lcde = 0 'E1 (Enable the first HD44780)
Cls
Cursor Off
'--------------------------------------------------
'--------------------------------------------------
' clear line 3 and line 4 and set cursor off
___lcde = 1 'E2 (Enable the second HD44780)
Cls
Cursor Off
'--------------------------------------------------
'--------------------------------------------------
' write on line 1 and line 2
___lcde = 0 'E1 (Enable the first HD44780)
Locate 1 , 1
LCD "Line 1-890123456789012345678901234567890"
Locate 2 , 1
LCD "Line 2-890123456789012345678901234567890"
'--------------------------------------------------
'--------------------------------------------------
' write on line 3 and line 4
___lcde = 1 'E2 (Enable the second HD44780)
Locate 1 , 1
LCD "Line 3-890123456789012345678901234567890"
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum