3
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ This community does not respond very well to questions that simply ask for code. Perhaps you can start with what you've tried and debugged so far. If you can narrow your question down to a specific problem then you're likely to get a good answer. Have you read the LCD datasheet and observed the outputs of your microcontroller to ensure that it's doing what you want it to? \$\endgroup\$ – Jon L May 6 '12 at 4:17
  • \$\begingroup\$ You want me to post all my code? I could if you like.Yes, I've debugged and and everything looks correct. I'm sending 0x03 to the controller three times with 5ms/5ms/100ns delays between each send. The delays seem to variable depending on who's code I'm copying from. The Watch widow shows output is as expected. Sending 0x02 next to put in 4bit mode then sending the additional function set.As the display never turns on or off, which is part of the function set instructions, this tells me I'm not even initializing it.I've followed PICs lcd_init(), a couple of online guides.Nothing is working. \$\endgroup\$ – Chef Flambe May 6 '12 at 4:31
  • \$\begingroup\$ I have had the same kind of problem. I still have not got a single 44780 lcd to work with any kind of device. I have tried multiple displays, one of which might have been broken. They just put half of the characters black, or don't do anything :( \$\endgroup\$ – varesa May 6 '12 at 6:39
2
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.