Only I do not quite understand why the B1 lead is used as the LCD D4 driver. I used the B.4 for that, it makes outputting the data so much easier.
Sorry, I wrote this without really reading the comments. I DO understand now why
inglewoodpete did that when I looked closer at those. But since I am using the 28X2 and 40X2 ships only, I changed it.
Also, I am planning to change the write command to the following code to take advantage of the SHIFT instruction of the X2 parts:
'Assuming the LCD DATA leads are connected to B4-B7
out_cmd:
Low oLCDRS
out_data:
b2 = b0
outpinsB = b0
pulseout oLcdEn, 2
b0 = b2 << 4 'shift LSB in MSB
pause 4
outpinsB = b0
pulseout oLcdEn, 2
High oLCDRS
pause 4
Return
And here is the code that did not work. Connections are for an New Haven 8 BIT LCD connected to the B0-7 port. There are a few things that do not show but I tried later on, with no success.
1. using a reset code of $38 three times at the start and
2. using the PULSEOUT instruction instead of manually manipulating the E lead.
Also I understand that by sending an $0F as the very first command, you should see a
Cursor with Underline flashing on your LCD and know that everything is working as it should. That did not happen in my case.
I am not even sure that the following program is the one I ended up with. I changed things in an attempt to get it working. But here it is
#rem
FILE: New Haven LCD.bas Version 1.0
This is the program for the New Haven C0220AU LCD
---------------------------------------------------------------------------
This uses the PICAXE 40x2 chip
----------------------------------------------------------------------------
#endrem
'Following is associated with the LCD Pin Outs Pin4 - Pin14
symbol rs = D.0 'Mode H=Cmnd, L=Data
symbol rw = D.1 'R/W = High/Low
symbol e = D.2 'enable
'Init Codes of LCD = 3C-0E-01-03
'2line/5x10--displ ON,cursor OFF,blink OFF--Clear Displ--Increment,shift ON
symbol code1 = 0x3c
symbol code2 = 0x0e
symbol code3 = 0x01
symbol code4 = 0x03
'Following is the data to be displayed
symbol digit1 = 0x31 '1
symbol digit2 = 0x32 '2
symbol digit3 = 0x33 '3
'---------------------------------------------------
'PORT assignments
dirsB = 0xFF 'LCD 8-Bit DATA Port
dirsD = 0xFF 'LCD Control Port
outpinsB = 0xFF 'all LCD Data=High
outpinsD = 0xFF 'all LCD Control Lines=HIGH
'-------------- We are starting here --------------------
'intialize LCD 3X
for b0 = 1 to 3
b1 = code1
gosub out_cmnd
b1 = code2
gosub out_cmnd
b1 = code3
gosub out_cmnd
b1 = code4
gosub out_cmnd
pause 50
next
main:
high e
high rs
b1 = digit1
gosub out_data
pause 5
b1 = digit2
gosub out_data
pause 5
b1 = digit3
gosub out_data
pause 400 'wait
goto main 'and do it over again
out_cmnd:
low rs
out_data:
outpinsB = b1
pause 1
low e
pause 2
high e
pause 3
return
end