parallel lcd control
chrillz
Posts: 3
I have just got an parallel lcd working following an example from http://www.weethet.nl/english/basicstamp2_lcdcontrol.php, but I don't understand why my lcd (a 16x1) doesn't print more than 8 characters? I can't figure out how to utilize the whole row of the lcd.
the code is:
the code is:
' -----[noparse][[/noparse] Constants ]------------------------------------------------------- ' RS CON 4 ' Register Select (1 = char) E CON 5 ' LCD Enable pin (1 = enabled) ' LCD control characters ' ClrLCD CON $01 ' clear the LCD CrsrHm CON $02 ' move cursor to home position CrsrLf CON $10 ' move cursor left CrsrRt CON $14 ' move cursor right DispLf CON $18 ' shift displayed chars left DispRt CON $1C ' shift displayed chars right DDRam CON $80 ' Display Data RAM control ' -----[noparse][[/noparse] Variables ]------------------------------------------------------- ' char VAR BYTE ' character sent to LCD index VAR BYTE ' loop counter ' -----[noparse][[/noparse] EEPROM Data ]----------------------------------------------------- ' Msg DATA "BASIC Stamp 2 LCD in action" ' preload message ' -----[noparse][[/noparse] Initialization ]-------------------------------------------------- ' Init: DIRL = %00111111 ' set pins 0-5 as outputs OUTS = $0000 ' clear the pins ' Initialize the LCD (Hitachi HD44780 controller) ' LCDinit: 'pause 500 ' Wait for LCD init ' ================================= ' STANDARD HITACHI 44780 4-BIT INIT ' ================================= char=%00000011 ' Set 8-bit mode (1) GOSUB LCDCMD char=%00000011 ' Set 8-bit mode (2) GOSUB LCDCMD char=%00000011 ' Set 8-bit mode (3) GOSUB LCDCMD char=%00000010 ' Set 4-bit mode GOSUB LCDCMD char=%00101111 ' Set duty cycle 11xx = 5x11 matrix GOSUB LCDCMD ' 10xx = 5x8 matric char=%00000000 ' Display control mode GOSUB LCDCMD char=%00001000 ' Set display OFF, cursor OFF, blink OFF GOSUB LCDCMD char=%00000000 ' Display control mode GOSUB LCDCMD char=%00001111 ' Set display ON, cursor ON, blink ON GOSUB LCDCMD ' 11CB -> C=1 cursor on, B=1 blink on char=%00000000 ' Entry control mode GOSUB LCDCMD char=%00000110 ' Set cursor right, no display shift GOSUB LCDCMD ' 01IS -> I=1 cursor right, S=1 shift display char = ClrLCD ' Clear LCD GOSUB LCDCMD ' -----[noparse][[/noparse] Main Code ]------------------------------------------------------- ' Start: FOR index = 0 TO 39 READ Msg + index, char ' get character from EEPROM 'char=index GOSUB LCDwr ' write it NEXT PAUSE 1000 ' wait 2 seconds char = ClrLCD ' clear the LCD GOSUB LCDCMD PAUSE 500 GOTO Start ' do it all over ' -----[noparse][[/noparse] Subroutines ]----------------------------------------------------- ' ' Send command to the LCD ' LCDcmd: LOW RS ' enter command mode ' ' Write ASCII char to LCD ' LCDwr: OUTA = char.HIGHNIB ' output high nibble PULSOUT E, 1 ' strobe the Enable line OUTA = char.LOWNIB ' output low nibble PULSOUT E, 1 HIGH RS ' return to character mode RETURN
Comments
P.S. – If you write a program that keeps printing characters it should eventually show up on the second half of the display.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering