Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001
Page 30
' -----[ Constants ]------------------------------------------------------------
'
DevType CON %1010 << 4 ' device type
DevAddr CON %000 << 1 ' address = %000 -> %111
Wr2432 CON DevType | DevAddr ' write to 24LC32
Rd2432 CON Wr2432 | 1 ' read from 2 4LC32
MaxEE CON 4095 ' highest EE address
' LCD control characters
'
NoCmd CON $00 ' No command in LCDOUT
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
CGRam CON $40 ' Custom character RAM
Line1 CON $80 ' DDRAM address of line 1
Line2 CON $C0 ' DDRAM address of line 2
' -----[ Variables ]------------------------------------------------------------
'
addr VAR Word ' EE address
addrHi VAR addr.HighByte
addrLo VAR addr.LowByte
rVar VAR Word ' for random number
tOut VAR Byte ' test value to LCD
tIn VAR Byte ' test value read from LCD
temp VAR Word ' temp value for display
width VAR Nib ' width of rt justified
pos VAR Byte ' column position
digits VAR Nib ' digits to display
' -----[ EEPROM Data ]----------------------------------------------------------
'
Super2 DATA %01100 ' superscript 2 (custom char)
DATA %00010
DATA %00100
DATA %01000
DATA %01110
DATA %00000
DATA %00000
DATA %00000
' -----[ Initialization ]-------------------------------------------------------
'
LCD_Setup:
PAUSE 500 ' let the LCD settle
LCDCMD LCDpin,%00110000 : PAUSE 5 ' 8 -bit mode
LCDCMD LCDpin,%00110000 : PAUSE 0
LCDCMD LCDpin,%00110000 : PAUSE 0
LCDCMD LCDpin,%00100000 : PAUSE 0 ' 4-bit mode
LCDCMD LCDpin,%00101000 : PAUSE 0 ' 2 -line mode
LCDCMD LCDpin,%00001100 : PAUSE 0 ' no crsr, no blink
LCDCMD LCDpin,%00000110 ' inc crsr, no display shift