Electronic – PIC 18f4685 and Hitachi 44780 LCD

lcdpic

Anybody have some sure to work 4-bit interface C code for a PIC 18f4685 to Hitachi LCD 2-line display? I'm using a Northmicro proto board with a LCD module which is Hitachi 44780 compatible.
Using MPLab V8.x with C18 compiler.

Lower nibble on PORTB to D4-7

E:RA4

RS:RB4

RW:RB5

Backlight:RA5

I've looked all around Google land and have found stuff that should get me through the process but none have been written for my particular configuration. I've gone through and think I've tweaked them for my uses but I can't even get the LCD to initialize. Timing delays seem to be okay when I run it through the MPlabSim.

I've tried to use the libraries in the mcc18 src folder too but that didn't work either.

I'm looking for code that is known to work so I can troubleshoot if it's my crappy coding or the board. So far I've only been able to turn the backlight on and off but that doesn't really count as it's just a pin connected to a mosfet and has nothing to do with the onboard mcu of the LCD.

I've been at it for a few hours each day for the past week… 16 hours is a long time to spend on a silly project like this so I'd love it if I could get a helping hand with it please.

Thanks in advance.

Best Answer

You can get code that is known to work, but it will not be guaranteed to work on your particular hardware configuration. You will need to configure the code and maybe even modify it.

A couple of years ago, I wrote a simple LCD library. At the time, I used PIC18F4450, but I have also tried this code on PIC16F887. It should work with many chips, as long as you know what you do. To make things easy for you, it also has an example main.c file.