Hd44780 LCD

Hi, I'm new to Arduino, but not new to AVR's. I have exsisting hardware that is vased on the 32 pin Mega168 with no xtal. The LCD interface is wired for 4 pin mode and uses PB6 and PB7 (xtal pins) in the interface. I would like to use the Arduino IDE. PB4-PB7 are the data lines, PB0,PB1 and PB2 are RS, R/W and E.

My questions are:

  1. Is it possible to use the LiquidCrystal library with a different hardware interface?

  2. If so, what is the best way to implement and where?

Thanks, Phil

The standard arduino LCD library doesn't make any assumptions on how it is wired up, you are free to use any pins you like. However, it does rely on delays to ensure the LCD is ready to receive the next command. These of course will be based on the clock frequency. It is possible to hack the LCD library to make use of the read facilities to check the busy flag but I don't have a link to someone who has done this and put it on line. My latest project will include a hacked library that does this but it is not finished yet.

thank you for your reply, but I'm not sure I see the answer.

My understanding is the LiquidCrystal library is based on digital pins as defined in the Arduino board model.

PB6 and PB7 are crystal pins on all the boards I see. So how do I define a harware wiring map that allows me to define digital pins to PB6 and PB7?

You specify which Arduino pins correspond to which LCD pins when you invoke the library with one of the four possible commands.

From the reference material:

LiquidCrystal()

Syntax:
LiquidCrystal(rs, enable, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d4, d5, d6, d7)
LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)

Since you are using seven interface pins (four data lines, RS, R/W, and E) you would use the second example. Just substitute your seven desired Arduino pin numbers in the sequence specified in the syntax example.

Don

You specify which Arduino pins correspond to which LCD pins when you invoke the library with one of the four possible commands.

From the reference material:

LiquidCrystal()

Syntax: LiquidCrystal(rs, enable, d4, d5, d6, d7) LiquidCrystal(rs, rw, enable, d4, d5, d6, d7) LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7) LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)

Since you are using seven interface pins (four data lines, RS, R/W, and E) you would use the second example. Just substitute your seven desired Arduino pin numbers in the sequence specified in the syntax example.

Don

Thanks, but that maps adruino digital pins, and PB6- PB7 aren't mapable via the arduino map.

I guess I misinterpreted your original question.

  1. Is it possible to use the LiquidCrystal library with a different hardware interface?

That depends on how different the hardware and/or the interface is. If you must use PB6 and PB7 then I think you are out of luck. You don't need to implement R/W since it is not used by any of the current LiquidCrystal routines. This leaves six lines which can be accommodated by PB0-PB5.

  1. If so, what is the best way to implement ...

You would have to have some way to program your chip with a bootloader. You would also have to use a version that runs at your 8MHz clock frequency (I believe that there is one available) and hope that your clock frequency is accurate enough.

... and where?

???

It would be far easier for you to write your own LCD routines for your current hardware/software setup. You can get most of what you need by examining the LiquidCrystal.cpp file.

Don