There's something I don't understand
Posted: 14 February 2010, 11:38 AM
Further to my earlier post, i was looking for a way to drive my LCD in 8 bit mode, using pins that do not necessarily all come from one port. (I expect in due course I will switch to 4 bit mode but so I can get on with other elements of the project I decided to try a quick and dirty fix)
The code I had from the sample on the website, used an alias technique to assign the data to the pins. So I figure if the pins might be anyhow numbered why not just have a table and do this :-
if LCD_Alias=true then
LCD_Data = C else
for i=0 to 7
call PutPin(LCD_Pin(i),GetBit(C,i))
next i
so this code should in theory cope with either scenario depending on the setting of a variable.
If I define my pins like this:-
LCD_Pin(0)=A.0
LCD_Pin(1)=A.1
LCD_Pin(2)=A.2
LCD_Pin(3)=A.3
LCD_Pin(4)=A.4
LCD_Pin(5)=A.5
LCD_Pin(6)=A.6
LCD_Pin(7)=A.7
it seems to work, however if I use pin number instead of A.n etc i get a different result, the top line of the lcd is quite unreadable with nothing on line 2.
also, demonstrating that there is something i don't understand, if i use the working method to define the pins, then i swap 2 wires on the ZX24, and swap the corresponding pin designations i still get slightly garbled output on the lCD, when i was hoping if i swap 2 wires, and swap and the table entries in LCD_Pin the resuilt would still work.
i though aliasing was just a shorthand for referencing variables but there seems to be more going on than that would suggest.
thanks
The code I had from the sample on the website, used an alias technique to assign the data to the pins. So I figure if the pins might be anyhow numbered why not just have a table and do this :-
if LCD_Alias=true then
LCD_Data = C else
for i=0 to 7
call PutPin(LCD_Pin(i),GetBit(C,i))
next i
so this code should in theory cope with either scenario depending on the setting of a variable.
If I define my pins like this:-
LCD_Pin(0)=A.0
LCD_Pin(1)=A.1
LCD_Pin(2)=A.2
LCD_Pin(3)=A.3
LCD_Pin(4)=A.4
LCD_Pin(5)=A.5
LCD_Pin(6)=A.6
LCD_Pin(7)=A.7
it seems to work, however if I use pin number instead of A.n etc i get a different result, the top line of the lcd is quite unreadable with nothing on line 2.
also, demonstrating that there is something i don't understand, if i use the working method to define the pins, then i swap 2 wires on the ZX24, and swap the corresponding pin designations i still get slightly garbled output on the lCD, when i was hoping if i swap 2 wires, and swap and the table entries in LCD_Pin the resuilt would still work.
i though aliasing was just a shorthand for referencing variables but there seems to be more going on than that would suggest.
thanks