Search This Blog

Saturday, October 22, 2011

Serial LCD With 74HC595

   Worked this weekend on writing to an Hitachi style 2 line, 16 character LCD.  I've posted on this before, but this time I tried a few new things.  First, I'm using the 18F2455.  To slow things down, I'm using a 4 MHz crystal.  I wanted to reduce the number of wires involved in steps.  First, I got the write working in 4 bit mode.  This is where you write a nibble at a time to the RD4-7 pins of the LCD.  Then, I got rid of the busy flag checks I'd used in the past.  I simply wait the maximum time for each operation.  This is 200us for data writes and 5ms for instruction operations.
   Then, the interface wanted less wires.  I added a 74HC595 shifter.  I initially kept the lcd strobe (E) pin on the microcontroller.  This meant I only needed three pins to write to the LCD: E, data, and clock.  Myke Predko passed on a tip he got from an old magazine article.  This lets you set up an AND gate between the 8th pin of the shifter and the data line.  With careful handling, this can serve as the E pin.  I'm attaching a code sample and schematic.  The schematic is illustrative but not exact.  I wouldn't try to create a board from it....
   I plan on making a small backpack for my LCD with the AND gate, the potentiometer, the shifter, and pins for the LCD.

Here's the sample code: lcd-serial.asm
Here's the schematic: