LCD in 4 bit mode!! Bit level manipulation
Sabre00
Posts: 30
I was doing some reading on the Propeller chip and it seems very interesting. My university supervisor introduced me to the chip and said to give is a try. I am working on a project that needs an LCD screen attached to it and I to conserve I/O pins I am using it in 4-bit mode. I was searching through the manual looking for bit level manipulation for a byte. Since there is a byte level manipulation for a word I saw that bit wasn't a predefined word. So I Came up with the following code taking the example from the outa and dira command;
*note* LCD_DATA is the byte variable that holds the data to be sent to the LCD
outa[noparse][[/noparse]D4] := 0
if LCD_Data [noparse][[/noparse]7]== 1
outa[noparse][[/noparse]D4] := 1
outa[noparse][[/noparse]D3] := 0
if LCD_Data [noparse][[/noparse]6]== 1
outa[noparse][[/noparse]D3] := 1
outa[noparse][[/noparse]D2] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D2] := 1
outa[noparse][[/noparse]D1] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D1] := 1
outa[noparse][[/noparse]D4] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D4] := 1
outa[noparse][[/noparse]D3] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D3] := 1
outa[noparse][[/noparse]D2] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D2] := 1
outa[noparse][[/noparse]D1] := 0
if LCD_Data [noparse][[/noparse]0]== 1
outa[noparse][[/noparse]D1] := 1
I have compiled it but I haven't physically gotten around to connecting it to the LCD as yet. Am I going the right way or is there a bit level manipulator that I overlooked.
Post Edited (Sabre00) : 9/16/2008 10:10:09 AM GMT
*note* LCD_DATA is the byte variable that holds the data to be sent to the LCD
outa[noparse][[/noparse]D4] := 0
if LCD_Data [noparse][[/noparse]7]== 1
outa[noparse][[/noparse]D4] := 1
outa[noparse][[/noparse]D3] := 0
if LCD_Data [noparse][[/noparse]6]== 1
outa[noparse][[/noparse]D3] := 1
outa[noparse][[/noparse]D2] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D2] := 1
outa[noparse][[/noparse]D1] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D1] := 1
outa[noparse][[/noparse]D4] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D4] := 1
outa[noparse][[/noparse]D3] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D3] := 1
outa[noparse][[/noparse]D2] := 0
if LCD_Data == 1
outa[noparse][[/noparse]D2] := 1
outa[noparse][[/noparse]D1] := 0
if LCD_Data [noparse][[/noparse]0]== 1
outa[noparse][[/noparse]D1] := 1
I have compiled it but I haven't physically gotten around to connecting it to the LCD as yet. Am I going the right way or is there a bit level manipulator that I overlooked.
Post Edited (Sabre00) : 9/16/2008 10:10:09 AM GMT
Comments
All other bit manipulation in Spin is done using logical operations on bytes, words, and long words including | for OR, & for AND, ! for NOT, and various shifts (see the Manual). Note that this special bit string access notation only applies to certain special I/O variables.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Thanks again guys. I noticed that there are I2C objects in there as well so I would see if I can use any of those in my project.