Connect with us

4bit LCD PIC program

Discussion in 'Electronic Design' started by Chris Gentry, Jun 18, 2005.

Scroll to continue with content
  1. Chris Gentry

    Chris Gentry Guest

    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 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...
  2. Bob Monsen

    Bob Monsen Guest

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

    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.

    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
  3. Steve Sousa

    Steve Sousa Guest

    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
  4. HD44100 is the expansion chip, the one he wants is the HD44780.

    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.
  5. Chris Gentry

    Chris Gentry Guest

    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...
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day