HD44780-based Alphanumeric LCDs

These modules are a common choice for microcontroller projects They are readily available and cheap, however a number of variations exist Note that the IC has several software-compatible near-equivalents so even if the module does not have a HD44780 on it may be compatible

Typical display configurations

Modules with only the controller IC

  • On its own the HD44780 supports 2 lines of 8 characters
  • Alternatively it may be used for one line in a 5x10 character format, this is unusual
  • Sometimes a 16 character display will be implemented as two lines of 8 characters

Modules with additional segment drivers

  • Displays longer than 8 characters require one or more segment driver ICs
  • As standard the HD44780 supports up to 2 lines of 40 characters
  • An alternative layout gives 4 lines of 20 characters, its effectively the 2*40 configuration, but split so the display goes Line 1 1-20, Line 2 1-20, Line 1 21-40, Line2 21-40

4 line 40 character modules

  • This pattern is typically implemented as two HD44780 controllers and two 2-line displays sharing the same glass
  • As the HD44780 lacks a "Chip Enable" pin expect to find two "E" pins
  • Typically all other inputs are common
  • This display pattern may not have a "standard" pinout
  • If you have one of these without a datasheet then you'll probably need to "buzz through" with a continuity tester to confirm pinout

Typical Pinout for a single controller module

A common arrangement is a single row of 14 pins or two rows of 7 pins using the odd-row, even-row pattern

  • Pin 1 Ground
  • Pin 2 Vcc (5v typically)
  • Pin 3 Vo/bias (Ground typically, may need negative supply)
  • Pin 4 RS (Register select)
  • Pin 5 R/!W (Data direction, sometimes tied to ground)
  • Pin 6 E (Enable, idles LOW and data is loaded on falling edge)
  • Pin 7 D0 (Optional)
  • Pin 8 D1 (Optional)
  • Pin 9 D2 (Optional)
  • Pin 10 D3 (Optional)
  • Pin 11 D4 (Data in)
  • Pin 12 D5 (Data in)
  • Pin 13 D6 (Data in)
  • Pin 14 D7 (Data in)
  • Pins 15 and 16 may connect to a backlight if fitted

Timing considerations

Enable has a minimum pulse width of 250ns (6502 CPU @ 2MHz)

RS and R/W should be valid before E rises

D pins are usually output first but only need to be valid in time for falling edge of E

Supply voltage considerations

5v Vcc operation

Update: Powered from 5v the inputs are not strictly 3.3v compatible, the minimum voltage for "High" is given as 0.7*Vcc, e.g. 3.5v. For hobby projects it should work but for commercial applications this must be checked. On closer examination the HD44780U datasheet I have (revision 0.0?) gives different input thresholds for the wide range: VCC = 2.7 to 4.5 V and for the narrower range: VCC = 4.5 to 5.5 V, and in the second case the positive input threshold IS 2.2V as stated in the LCD library documentation, so the inputs are 3.3v compatible. The ST7066 datasheet is clearer and gives a single VIH value of 2.2V over the range 2.7-5.5v. 5v operation is the "default" for most modules, and you can generally expect good contrast if you tie Vo to ground. One useful guideline I've seen is that if the user has the freedom to tilt the display then you may get away with fixed contrast, but if the display is in a fixed location the contrast should be adjustable. If you get a very faint display you may have a "extended temperature" type, these require a negative Vo. Display application data for an extended temperature type will often include a temperature-compensation circuit to automatically adjust Vo. Alternatively you may be operating a one-line display in two-line mode. In one-line mode the display is refreshed twice as often. This is why an un-configured two-line module may display dark squares on its top line, the top row is scanned twice as often so it responds to the residual "off" voltage.

3.3v Vcc operation

Powered from 3.3v the inputs will be fully 3.3v compatible. they are anyway, sorry. 3.3V modules are available. As far as I am aware these use a more sensitive LCD that requires a bias of 3.3V or less.

3.3v Vcc operation of a 5v rated module

If the module is intended for 5v operation then the 3.3v supply will give insufficient contrast. With Vo grounded the display text may be almost invisible. On the units I've seen if you get the light and angle right it is just about visible. The solustion is to supply a negative contrast voltage.The key is that the contrast voltage is Vcc-Vo so if Vo was connected to -1.7v then the total contrast supply would be 5v, enough to properly operate the LCD even though the logic supply is lower. Vo is a relatively high impedance input and is well suited to powering from a charge-pump. The 3.3v Vcc, negative Vo option is attractive for MBED projects as it allows the use of readily available LCD units, but allows powering from MBED Vout so the display operates equally well for USB or Vin power.

Control from software

There is a choice of two connection methods, 4-bit or 8-bit, also you have the option of fixed timing or busy-polling. Most library code around tends to support 4-bit fixed timing, and it is often a good choice but not always.

4 bit mode

In 4 bit mode each byte is sent as two half-bytes, high bits first. This cuts down on the number of interface lines required. It is important to maintain synchronisation. On successful power-on-reset the device will be in 8 bit mode, so initially we must send only the top half of the configuration command, then wait for completion. Once 4 bit mode is achieved then both halves of the command may be sent.

I would advise against reading from the display in 4 bit mode. While it is supported my experience has been frequent losses of synchronisation.

8 bit mode

In 8 bit mode all 8 data lines are used. This requires more interface lines but cuts down the number of I/O operations required. This mode might be used if there is already an 8-bit-wide peripheral in a system.

Fixed timing mode

In fixed timing mode the host microcontroller sends a command then waits a set time to allow the display to execute the command. Most operations are completed in 40us but the clear and home commands may take 1.6ms (these commands may be recognised as they both have the top six bits clear, so if (command and 0xfc) = 0 then wait). Many libraries implement this, as it is simple and works fine whether the display is connected or not. Unfortunately it can waste a lot of CPU time.

Timing in more detail

It is necessary to "read between the lines" of the datasheet to properly understand the timing. The command table gives delays for a 270kHz clock frequency, and with that frequency the command delay is 37us, and the long command delay is 1.52ms.

The initialisation sequence uses delays of 4.1ms and 100us. If we assume that the delay is inversely proportional to the clock then it appears that the initialisation sequence assumes a worst case clock of 100kHz. This would seem remarkably low.

If timing problems are observed then remember that it is not just the short instruction delay that needs scaling up, the long delay needs scaling up too.

A simple calculation gives the clock period as 3.7us, implying it takes 10 clock cycles to write one character. The clear delay appears to be 41 times longer, suggesting that a clear operation requires one horizontal "sweep" of the display. As a two line display has 80 characters of memory presumably it is erasing two characters at once.

In my experience it is allowing insufficient time for a "clear" instruction that causes the most problems. In my designs it resulted in a blank display, probably due to a cut-off command being mistaken for display-off.

Busy poll mode

In busy poll mode the driver code reads the display's busy flag to determine if it is ready. This requires more work from the microcontroller, but may be preferable in some round-robin-poll applications where if the display is busy it can be skipped and other tasks executed

Polling appears unreliable in 4-bit mode. This may depend on construction but in my experience synchronisation was lost resulting in incorrect BUSY status.

Software initialisation sequence

This is a special way to initialise the display from an unknown state. This is required if the power supply rise time is too long to satisfy the display's internal power on reset, or if the microcontroller has been restarted from an arbitrary point, leaving it out of step.

The sequence consists of sending the 8-bit-mode command repeatedly at set intervals to get the display into 8 bit mode. Then if 4 bit mode is desired then the top half of the 4 bit mode command can be set. The full sequence is:

  • Wait 15ms after power-on (MBED reset timing may take care of this).
  • Send command 0011xxxx as one operation, bottom 4 bits are don't care
  • Wait 4.1ms minimum as this could take a long time: If the display had recieved half a command beginning "0000" then the previous operation would trigger a "return home" command which is slow.
  • Send command 0011xxxx as one operation, bottom 4 bits are don't care
  • Wait 100us minimum
  • For 8 bit mode Send command 0011xxxx as one operation (bottom 4 bits are don't care)
  • For 4 bit mode Send command 0010xxxx as one operation (bottom 4 bits are don't care)

After this last operation the busy flag will be valid and the display should return to normal execution times. After this you need to send normal initialisation e.g.

  • a complete display mode command
  • display on/off
  • display clear
  • entry mode set.


1 comment on HD44780-based Alphanumeric LCDs:

17 Oct 2013

Hi Oliver, you may want to take a look at the cookbook page on the improved version of the TextLCD library here

Please log in to post comments.