Maker Pro
Maker Pro

4bit LCD PIC program

C

Chris Gentry

Jan 1, 1970
0
I've googled for a 4bit LCD PIC program and I've come up with several. I'm
not really sure what I'm looking for though. I've been using a pic16f873a
uC, and every bit of assembly code I've tried to run for my LCD doesn't
work. I've checked the obvious, like contrast and physical hookups. My LCD
is a 24X2 character unit from crystalfontz.com. It has an industry standard
driver. Maybe someone here could point me in the right direction on where
to find simple, easy to use code to work my LCD in 4 bit mode. Short of
something that I can cut-n-paste, maybe someone could show me a good article
on LCD assembly programming for a PIC. I'm not afraid to research on this,
just would like your opinion on what code to use. Thanks...
 
B

Bob Monsen

Jan 1, 1970
0
Chris said:
I've googled for a 4bit LCD PIC program and I've come up with several. I'm
not really sure what I'm looking for though. I've been using a pic16f873a
uC, and every bit of assembly code I've tried to run for my LCD doesn't
work. I've checked the obvious, like contrast and physical hookups. My LCD
is a 24X2 character unit from crystalfontz.com. It has an industry standard
driver. Maybe someone here could point me in the right direction on where
to find simple, easy to use code to work my LCD in 4 bit mode. Short of
something that I can cut-n-paste, maybe someone could show me a good article
on LCD assembly programming for a PIC. I'm not afraid to research on this,
just would like your opinion on what code to use. Thanks...

The main problem with these things is initialization. Does it
initialize? You need to wait ungodly amounts of time before it starts
talking.

The first time I tried this, though, I had some problems, so I built a
little breakpoint routine that would wait for button presses before
proceeding. With that, a listing, and a multimeter, it was easy to
figure out what was going wrong. If you do this, make sure you debounce
the button.

--
Regards,
Bob Monsen

If a little knowledge is dangerous, where is the man who has
so much as to be out of danger?
Thomas Henry Huxley, 1877
 
S

Steve Sousa

Jan 1, 1970
0
Chris Gentry said:
I've googled for a 4bit LCD PIC program and I've come up with several. I'm
not really sure what I'm looking for though. I've been using a pic16f873a
uC, and every bit of assembly code I've tried to run for my LCD doesn't
work. I've checked the obvious, like contrast and physical hookups. My
LCD is a 24X2 character unit from crystalfontz.com. It has an industry
standard

Get the hd44100 datasheet or the one for the chip on your module, turn to
the page with the timings for each command, now check your initialization
routine, are you waiting ~5ms on one of the steps? you should...

Best Regards
 
S

Spehro Pefhany

Jan 1, 1970
0
Get the hd44100 datasheet or the one for the chip on your module, turn to
the page with the timings for each command, now check your initialization
routine, are you waiting ~5ms on one of the steps? you should...

Best Regards

HD44100 is the expansion chip, the one he wants is the HD44780.

http://web.media.mit.edu/~ayah/documents/hd44780u.pdf

As far as I can tell, the clones (Samsung?) behave close enough to the
same as the original and 2nd generation Hitachi parts.

You'll probably find it easier and more satisfying to just write the
firmware from scratch rather than trying to debug all the random
errors you'll find in the stuff you can download. Some of it will
probably break or will be unreliable if you go, say, from 4MHz to
20MHz even if you fix the delays (because of setup and hold times).

In particular, make sure your delay routines are really generating the
required delays. I've seen gross errors, even in delay routines
distributed with expensive compilers. You can easily use the stopwatch
function in MPLAB to verify the delays.
 
C

Chris Gentry

Jan 1, 1970
0
Spehro Pefhany said:
HD44100 is the expansion chip, the one he wants is the HD44780.

http://web.media.mit.edu/~ayah/documents/hd44780u.pdf

As far as I can tell, the clones (Samsung?) behave close enough to the
same as the original and 2nd generation Hitachi parts.

You'll probably find it easier and more satisfying to just write the
firmware from scratch rather than trying to debug all the random
errors you'll find in the stuff you can download. Some of it will
probably break or will be unreliable if you go, say, from 4MHz to
20MHz even if you fix the delays (because of setup and hold times).

In particular, make sure your delay routines are really generating the
required delays. I've seen gross errors, even in delay routines
distributed with expensive compilers. You can easily use the stopwatch
function in MPLAB to verify the delays.

I do have the datasheets on my parts, but wasn't paying close enough
attention to the code. The timing could be the problem. I haven't verified
this, but I'm sure that the code was running at 4MHz and I have a 20MHz
xtal. I'll rewrite the delays, and give it a try. Thanks...
 
Top