I've been playing around with LCD drivers for a while now...mainly to keep the brain working and am now using a 14M2 to drive a parallel 2 line LCD. The problem is when I have the RS and E control lines on the same output port as the data lines and try to use a bit of "binary maths" to preserve the RS line condition as per the attached code no data appears to get to the LCD, that is it won't initalise. When I move the RS and E lines to port C as per the commented out code all works fine. Is the problem in my "binary maths" or is it some other cause. Using the simulator all the data appears to be correct.
Mick
Mick
Code:
#picaxe 14m2 ' AXE132 4Bit marks
' DB4 = B.0
' DB5 = B.1
' DB6 = B.2
' DB7 = B.3
SYMBOL E = B.4
SYMBOL RS = B.5
'SYMBOL E = C.0
'SYMBOL RS = C.1
SYMBOL RX = C.4
SYMBOL Backlight = C.2
SYMBOL senddata = b1
SYMBOL index = b0
SYMBOL estart = b2
SYMBOL eend = b3
SYMBOL RSdata = b4
SYMBOL baud = N9600_32
SYMBOL line_length = 16
SETFREQ M32
dirsB = %11111111
dirsC = %11010111
LOW Backlight
Gosub Initialise
Initialise:
FOR index = 0 to 6
LOOKUP index, ($33,$32,$28,$0C,$01,$02,$06),senddata : GOSUB Send ' Initialise LCD
'(WakeUp)*3(Set4Bit)(4Bit/2Line)(DisplayOn)(Clear Display)(Return Home)(Entry Mode Set)
NEXT index : PAUSE 10
Display:
LOW RS ' commandmode
senddata = $01 : GOSUB Send : PAUSE 10 ' Clear Display
senddata = 192 : GOSUB Send ' (192-211) Line 2 Cursor Position
HIGH RS ' charactermode
FOR index = 0 TO 13
LOOKUP index,("Serial-LCD Axe"),senddata : GOSUB Send ' sending characters
PAUSE 1000
NEXT index
PAUSE 1000
GOTO Main
Send:
RSdata = outpinsB & %00100000 'RS is on pin B.5 Need to add this to pins data
'pinsB = senddata / 16 : PULSOUT E,1
pinsB = senddata / 16 & %00001111 + RSdata : PULSOUT E,1 'MSB + RS pin out
'pinsB = senddata : PULSOUT E,1
PinsB = senddata & 00001111 + RSdata : PULSOUT E,1 'LSB + RS pin out
RETURN