Driving an LCD Display

The HD44780 LCD display controller is widely used in all sorts of devices. This program makes use of two source files. display.c provides a set functions that control the display. main.c provides a usage example. The display is wired in 4 bit mode (see the datasheets for the HD44780 chipset and the pinout for the model in question the MDLS 16166)
To summarize the display is connected as follows:
GPIOB bits 4 to 7 are connected to DB4 to DB7 on the display
GPIOB bit 13 is wired to the RS (register select) pin on the display
GPIOB bit 14 is wired to the R/W pin on the display
GPIOB bit 15 is wired to the E (clock) pin
The display is programmed on the assumption that it is a write-only device (the R/W line is never set to 1).
display.c exposes the following functions to the user :
void initdisplay(): This function initializes the LCD display.
void puts(char *str): This function prints the given string to the display
void putc(char c): This function prints the given character to the display
void printbyte(unsigned int b): Prints the byte b in hex on the display
void printhex(unsigned int d): The parameter d is treated as a 16 bit value and printed to the display in hex
void printshort(short d): The parameter d (16 bit) is printed in decimal to the display

Code, makefiles and scripts are provided here

Click the image below to zoom


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s