Introduction
This program makes use of two source files. display.c provides a set functions that contol the display. main.c provides a usage example.
HD44780 and compatible LCD displays
The display is connected to GPIOB in 4-bit mode (see the datasheets for the HD44780 chipset and the pinout for the model in question) 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
Using the display library
My setup looks like this:
Code, makefiles and scripts are provided here