So, you have a small LCD character display, with a Hitachi HD44780 compatible controller and a PIC. You want to control the LCD display from the PIC. There seems to be quite a bit of sample code on the web, however, it seems to either have been written or an alternative microcontroller or in assembly. Well, here’s a very basic library for writing to the controller from SDCC.
This library provides a wrapper over the configuration options provided by the Hitachi display; it provides a number of defines to make it easier to select individual options; a basic initialisation function and some very basic commands to send commands and data.
There are a number of defines in the header fine which allow the port used for the data bus and the control lines to be chosen. Note that you will need to provide the Tri-state buffers for these as well, so that the direction of the port and the control lines can be configured.
In my setup I have a PIC18f252 (running with a 20MHz crystal) and a Hitachi LM016L as shown in the schematic below:
Included in the archive is the library, a basic demonstration (complete with piklab project file and basic Makefile) and an image of the above schematic. I have included the demo in binary form as well. If setup correctly, the demo should display the first 16 letters of the alphabet in capitals on the top row and in lower case on the bottom.
29 Mar 2007 #electronics