This is an old revision of the document!
Published 17 Dec 2018
SPI LCD Driver Library
I have a couple of display panels, one from a Brother Fax, the other from a Panasonic phone, that I wish to use in Arduino projects. These are 1 line by 16 character LCD status displays, controlled by a Hitachi HD44780 compatible LCD controller/driver chip that uses an SPI serial interface.
I looked for an Arduino library that would talk to this chip-set, but failed to find one.
I based my library module for this on a standard Arduino library for the Hitachi HD44780 chip, LiquidCrystal.cpp. The programs included here are LCD_test.ino, LiquidCrystal_SPI.cpp and LiquidCrystal_SPI.h.
The command set is compatible with the Hitachi HD44780, but I don't know the model of the chip, or even the manufacturer.
The controller is mounted directly on the LCD glass, and the LCD module has a 6 pin, 1mm pitch, pcb flex cable. The displays are a single line of sixteen, 5 by 8 pixel, characters.
The two modules have different character sets, but the characters in common tend to have exactly the same font design, so they may have the same manufacturer. I experimented a little, but could not get either board to display an 5 by 11 character mode.
The great advantage of these serial SPI LCD modules is the simplicity of the Arduino interface. There are three signal lines MISO (data), SCLK (clock), and SS (select). Plus power (+5V) and ground.
The data clock is also the chip's clock that is used to produce the LCD scanning. The datasheet says 500kHz down to 125kHz, typically 250kHz. My board seemed to be quite happy to operate at 1MHz and was still working down to 50kHz, albeit with a lot of flicker. Data is clocked on the rising edge of the clock signal, starts with three low start bits, two register select bits (instruction, data, and two LED control registers), an 8 bit command or data, and at least one high stop bit. The register select and command/data words are sent least significant bit first.
A suitable clock signal can be generated from the Arduino using one of the timers (I have used Timer1), but the main difficulty is synchronising the data out from the Arduino to this clock. I could perhaps use timer interrupts to drive an output routine that puts out one bit at each clock pulse, but to do this in C in less than 8µS (125kHz clock) seemed difficult. For testing purposes I did something a bit simpler: In the data output routine, I simply turned off the timer clock and 'manually' generated clock and data pulses, then turned on the timer clock when finished. Although the resultant clock during data transmission is something like 73kHz, it seems to work fine. But I see when analysing the clock output that there are occasionally nasty short clock cycles when switching from timer clock to data clock and back. These have no effect upon the communication as they occur when the data pin is high and so don't generate spurious start bits etc, but probably aren't good for the driver chip or LCD.
There is no “busy” pin, so delays between commands are necessary, 80µS normally and 1640µS for display clear when using a 250kHz clock.
There was no contrast adjustment on this board.
The data pin could be most any Arduino pin, but the clock pin has to be one that can generate PWM outputs, and pin 9 was the appropriate pin when using Timer1 for this purpose.
As mentioned earlier the library is based on a standard Arduino HD44780 LCD library. Most T6A34 hardware commands, including programmable characters, seem to be compatible with the HD44780, but there are some minor variations when comparing datasheets.
The functions implemented are:
The functions appear to be the same as for the HD44780 but have not been extensively tested for compatibility.
The programs (v1.00):
If any referenced page no longer exists, try looking for its URL on http://archive.org.