Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC and 44780 LCD

Status
Not open for further replies.

fishcurry

New Member
Hi,

I'm using a 16f877, hitech C and (i think) a 44780 compatible LCD. I just want to get some basic text writing on the LCD going, but I can't even seem to do that. I am using the example code that came with the hitech compiler but with my own delay function, because that one was giving me undefined symbol errors. Anyways, all I've been able to write is just garbage that doesn't make sense and having the LCD flash a bit. I'm not even close to having something to write properly I don't think. I am using PORTD, for the data ports and to initialize that all I do is in my main(), write TRISD = 0; right? This is very annoying as I have absolutely no way of debugging, it's just trial and error all the way. If anyone can help me that would be a real bonus.

Thanks,


Arnold
 
hello,

the first thing that I think you should do is try and gain an understanding of how your lcd works... if you give me your email I will email you some usefull pdfs I have found... :)

portD is your data lines...
what port are you using to control the lcd (rw,rs, and e)?

yes, you have to do trisd=0, you also (if applicable) have to set port d to digital i/o (some ports do analog and digital)

you also have to configure the control lines as o/p

to initialize the lcd you have to do this:
[
rs=0
rw=0
portD=0x38
e=1
small delay (NOP)
e=0
]
delay 5 ms
[
rs=0
rw=0
portD=0x38
e=1
small delay (NOP)
e=0
]
delay 5 ms
[
rs=0
rw=0
portD=0x38
e=1
small delay (NOP)
e=0
]
delay 5 ms
[
rs=0
rw=0
portD=0x0c (lcd on)
e=1
NOP
e=0
[
rs=0
rw=o
portD=0x01 (lcd clr)
e=1
NOP
e=0
]
rs=0
rw=0
portD=0x06 (curser increment mode)
e=1
NOP
e=0
]

to send a character do this:
[
rs=1
rw=0
portD=(0x31 - will display a "1" on the screen)
e=1
NOP
e=0
]

NOTE: the only difference between sending commands (like clearing the lcd) and sending characters (like ascii 0x31) is the rs line... 1 = char, 0 = command :)
 
thanks\1

Yea, I think I had problems with initializing the ports that was the thing. I got it fixed now. Alright, I looked over the coding you have and the one on the piclist site is very similar to it. As with the code that comes with the hitech compiler. The piclist code (craig lee's) is as easy as 123. For those of you who are stuck chuck on LCD code, this is just cut and paste...



one thing, i've got an 8 x 2 LCD. How do i get to the second line? Lcd_goto doesn't seem to work...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top