Interfacing an LCD to an 8051. |
| Tuesday, 03 January 2006 00:24 | |||
|
LCDs are high up on the list of things to interface to because they provide a great way to debug your program and to display results to the outside world. Interfacing an LCD to a microcontroller can be a bit confusing if you haven't done it before. However, with a little work and determination you'll have your microcontroller yelling "Hello World" in no time. For this paper, I'll be interfacing directly to a HD44780 LCD controller. These LCDs are the most popular and easiest to procure. In fact, most text based LCDs are based on this chip. The HD44780 takes care of all the low level details when it comes to driving the LCD, you simply speak to the HD44780 and it takes care of the rest. There are many manufacterers but the main players are Hitachi, Sharp, and Optrex. If you are looking for a source for these LCDs goto ebay and search for "hd44780 lcd" or look in any electronic component supplier's catalogs. Specifically, I'll be using a Sharp LM40X21A LCD. This is a HD44780 based LCD with 2x20 characters (meaning two lines with twenty characters in each). First thing you'll want to do when you get your LCD board is look up the pin outs so that you understand where each of the singaling pins reside. I've saved a copy of the LM40X21A datasheets here. LCDs are typically very slow when compared to modern day microcontrollers so you'll need to make sure that you have your timing right. Otherwise, nothing will work. (again, if you have trouble, think timing) The HD44780A supports both an 8 bit and 4 bit interface. The 4 bit mode is essentially the same as the 8 bit mode but data transfers between the mcu and LCD controller are done in two cycles, a nibble (4 bits ) at a time. In the 4 bit mode data is transferred using lines BD7-DB4 lines DB3-DB0 are not used. The high order bit contents are transferred first (DB7-DB4) and then the low order (BD3-DB0). The 4-bit mode is useful when you are "low" on I/O lines, but I'm not "low" on I/O lines so I'll be controlling the LCD in the 8 bit mode. IPFW 304 Lab (I'm actually writing this document for this lab) Serial LCD Interface - some information Yet another 8051 to LCD program - C code for the Keil compiler 8051 LCD Keil SDCC LCD Project
|
|||
| Last Updated on Wednesday, 30 August 2006 14:47 |

