Hitachi HD44780 LCD controller


The Hitachi HD44780 LCD controller is an alphanumeric dot matrix liquid crystal display controller developed by Hitachi in the 1980s. The character set of the controller includes ASCII characters, Japanese Kana characters, and some symbols in two 28 character lines. Using an extension driver, the device can display up to 80 characters. The HD44780 is one of the most popular character LCDs ever made, with numerous third-party displays utilizing its 16-pin interface and instruction set for compatibility.

Architecture

The Hitachi HD44780 LCD controller is limited to monochrome text displays and is often used in copiers, fax machines, laser printers, industrial test equipment, networking equipment, such as routers and storage devices.
Compatible LCD screens are manufactured in several standard configurations. Common sizes are one row of eight characters, and 16×2, 20×2 and 20×4 formats. Larger custom sizes are made with 32, 40 and 80 characters and with 1, 2, 4 or 8 lines. The most commonly manufactured larger configuration is 40x4 characters, which requires two individually addressable HD44780 controllers with expansion chips as a single HD44780 chip can only address up to 80 characters.
Character LCDs may have a backlight, which may be LED, fluorescent, or electroluminescent.
Character LCDs use a 16 contact interface, commonly using pins or card edge connections on 0.1 inch centers. Those without backlights may have only 14 pins, omitting the two pins powering the light. This interface was designed to be easily hooked up to the Intel MCS-51 XRAM interface, using only two address pins, which allowed displaying text on LCD using simple MOVX commands, offering cost effective option for adding text display to devices. The pinout is as follows:
  1. Ground
  2. VCC +3.3 to +5V
  3. Contrast adjustment This is an analog input, typically connected to a potentiometer. The user must be able to control this voltage independent of all other adjustments, in order to optimise visibility of the display that varies i.a. with temperature, and, in some cases height above the sea level. With a wrong adjustment the display will seem to malfunction.
  4. Register Select. RS=0: Command, RS=1: Data
  5. Read/Write. R/W=0: Write, R/W=1: Read
  6. Clock. Falling edge triggered
  7. Bit 0
  8. Bit 1
  9. Bit 2
  10. Bit 3
  11. Bit 4
  12. Bit 5
  13. Bit 6
  14. Bit 7
  15. Backlight Anode
  16. Backlight Cathode
The nominal operating voltage for LED backlights is 5V at full brightness, with dimming at lower voltages dependent on the details such as LED color. Non-LED backlights often require higher voltages.

Mode selection

Selecting 4-bit or 8-bit mode requires careful selection of commands. There are
two primary considerations. First, with D3-D0 unconnected, these lines will
always appear low to the HD44780 when it is in 4-bit mode. Second, the
LCD may initially be in one of three states:
State3 may occur, for example, if a prior control was aborted after sending
only the first 4 bits of a command while the LCD was in 4-bit mode.
The following algorithm ensures that the LCD is in the desired mode:
  1. Set D7-D4 to 0b0011, and toggle the enable bit.
  2. # If in State1, the LCD will see the command as 0b0011_0000, and thus remain in 8-bit mode.
  3. # If in State2, the LCD will simply latch the value 0b0011 into bits 7-4 and then move to State3.
  4. # If in State3, the LCD will latch the value 0b0011 into bits 3-0, and then execute a random command based on the values in bits 7-4, after which it will either be in State1, or State2.
  5. Repeat the above, setting D7-D4 to 0b0011 and toggling the enable bit again.
  6. # If in State1, the LCD will remain in 8-bit mode just as above.
  7. # If in State2, it will latch the value into bits 7-4 and move to State3, just as above.
  8. # If in State3, the LCD will latch the value into bits 3-0 just as above and execute a command. However, the command will no longer be random, but will be the 0b0011 that was latched from State2 in the previous iteration. Thus, the LCD will switch to 8-bit mode and change to State1.
  9. The LCD is now in either State1 or State 3. Repeat the previous step one more time.
  10. # If in State1, the LCD will remain in 8-bit mode.
  11. # The LCD can no longer be in State2 at this point.
  12. # If in State3, the LCD will latch the value into bits 3-0 and execute a command, which will be the 0b0011 that was latched from State2 in the previous iteration, thus switching the LCD to 8-bit mode and State1.
  13. Now that the LCD is definitely in 8-bit mode, it can be switched to 4-bit mode if desired. To do so, set D7-D4 to 0b0010 and toggle the enable bit. This will leave the LCD in 4-bit mode, configured for a single line and 5x8 fonts.
  14. Issue any desired additional Function Set commands to specify the number of lines and the font to use, being sure to use the appropriate value for bit 4 so as to remain in the desired mode.
Once in 4-bit mode, character and control data are transferred as pairs of 4-bit "nibbles" on the upper data pins, D7-D4. The four most significant bits must be written first, followed by the four least significant bits.

Instruction set

The HD44780 instruction set is shown below:

Font

The original HD44780 character generator ROM contains 208 characters in a 5×8 dot matrix, and 32 characters in a 5×10 dot matrix. More recent compatible chips are available with higher resolution, matched to displays with more pixels.
Two versions of the ROM have been developed:
The 7-bit ASCII subset for the Japanese version is non-standard: it supplies a Yen symbol where the backslash character is normally found, and left and right arrow symbols in place of tilde and the rubout character.
A limited number of custom characters can be programmed into the device in the form of a bitmap using special commands. These characters have to be written to the device each time it is switched on, as they are stored in volatile memory.