Using two pcf8574p chips to drive an 8 bit 16x2 lcd

I currently have a prebuilt circuit I am trying to build a new processor board for but want to maintain as much of the original kit as possible. The 16x2 LCD connects to two PCF8574 chips and has the follow connections:

LCD Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Name VSS VDD Vo RS RW EN D0 D1 D2 D3 D4 D5 D6 D7
PCF8574P Pin 9 10 11 4 5 6 7 9 10 11 12
I/O pin P4 P5 P6 P0 P1 P2 P3 P4 P5 P6 P7
Address of chip 0x23 0x23 0x23 0x22 0x22 0x22 0x22 0x22 0x22 0x22 0x22

I can't find an LCD library to address an LCD that spans across two IO Expander chips.
Please help me write some code using something. Thanks

Sorry to maybe not have made it clear, the two chips are the first one handles LCD pins 4,5 and 6 and the second chip, all the rest of the pins.

Your best bet is to find a pre-written I2C LCD library for the PCF8574 and modify it. A quick Google search brings up this link that may help you.

OK Thanks, I will try to write something myself. Would have been great if an existing library supported spreading the pins over two chips.

nitrojet:
OK Thanks, I will try to write something myself. Would have been great if an existing library supported spreading the pins over two chips.

Did you look at the link I supplied? The site shows a schematic of 2x PCF8574 chips driving an LCD in 8 bit mode so maybe there library already does what you want.

I don't think the direction as to how to proceed is completely obvious.

If you are good at s/w then modifying an existing i2c library wouldn't be that bad but my guess
is it will probably take about the same amount of time as modifying the h/w to work in 4 bit mode with
an existing library.
I have done many i2c to hd44780 libraries and have been soldering for over 40 years
so for me, given how simple the h/w mod is (7 cuts, 3 wires) I think I could modify the h/w faster
than I could create and test a new library to work with two i2c i/o expanders.
Remember, not only do you have to modify the send() routine but you will also have to modify
the constructors to allow specifying the two i2c addresses.
And things start to more complicated and messy if you want/need to use the output port
pins that are not used by the LCD for something else.

Also consider this, while counter-intuitive,
using a single PCF8574 in LCD 4 bit mode can actually be faster.
Look at the i2c sequences for each:
These examples assume the library code is optimizing the updates to the i/o port
such that multiple i/o port updates are done per i2c bus acquisition
which most libraries don't do, but still shows what the "best case"
scenario is.

8bit mode using dual PCF8574
-START
-- 8 bits (7bit i2c address, r/w bit) address of data PCF8574
-- 8 bits ( 8bit LCD data)

  • STOP
  • START
    -- 8 bits (7bit i2c address, r/w bit) address of ctl PCF8574
    -- 8 bits ( RS, RW, EN LCD ctl) - with EN high
    -- 8 bits ( RS, RW, EN LCD ctl) - with EN low
  • STOP

4 bit mode:

  • START
    -- 8 bits (7bit i2c address, r/w bit)
    -- 8 bits (4 bit LCD data, RS, RW, EN LCD ctl) - with EN High
    -- 8 bits (4 bit LCD data, RS, RW, EN LCD ctl) - with EN low
    -- 8 bits (4 bit LCD data, RS, RW, EN LCD ctl) - with EN High
    -- 8 bits (4 bit LCD data, RS, RW, EN LCD ctl) - with EN low
  • END

As you can see the 8 bit dual chip mode transfers the same number of bytes on the bus,
(both 8 bit and 4 bit will transmit 5 bytes between the START/STOP);
however, 8 bit dual mode does more STARTS/STOPS on the bus than 4 bit mode
because of having to switch between chips so it will be slower because of that additional overhead.

Just something to keep in mind when considering which way to go.

--- bill