Upload
ira-allison
View
227
Download
1
Embed Size (px)
DESCRIPTION
Department of Electronic & Electrical Engineering Resources Powertip PC1601A 1x16 LCD data sheet (not much help) Hitachi HD44780 data sheet (lots of detail) (recommended) (I pinched this code) lcd4bitHello.asm (my example code )
Citation preview
Department of Electronic & Electrical Engineering
LCD character display (parallel interface).
How to interface a LCD character display to a PIC.
Department of Electronic & Electrical Engineering
Applications
Used in many devices which need a simple monochrome display:
FAX machines Phones. Industrial test equipment Volt meters Student projects ? Etc . . .
Department of Electronic & Electrical Engineering
Resources
Powertip PC1601A 1x16 LCD data sheet (not much help) Hitachi HD44780 data sheet (lots of detail) http://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller http://www.8051projects.net/lcd-interfacing/introduction.php (recommended) http://www.piclist.com/techref/microchip/4bitlcd-b.htm (I pinched this code) lcd4bitHello.asm (my example code ) http://www.geocities.com/dinceraydin/lcd/intro.htm
Department of Electronic & Electrical Engineering
POWERTIP PC 1601A Schematic
Showing the HD44780U and the LCD displayHD44780 (another micro controller!)
Department of Electronic & Electrical Engineering
Hitachi HD44780 LCD microcontroller
The HD44780 is a dot-matrix LCD controller Lots of LCDs use this controller. It provides the functionality and memory to drive the LCD. It allows you to use simple interface to drive the display A single HD44780 can display
one 8 characters line OR two 8 character lines one 16 character line (pretending to be 2 lines)
Can be driven using just 6 connection to the PIC
Department of Electronic & Electrical Engineering
PIN Descriptions
VSS Power supply (GND)VCC Power supply (+5V)VEE Contrast adjustRS 0 = Instruction input 1 = Data inputR/W 0 = Write to LCD module 1 = Read from LCD moduleEN Enable signalD0-7 Data bus lines 0-7
Department of Electronic & Electrical Engineering
Connections (4 bit mode)
RW can be set low because we will not be reading from device4bit mode does not use D0-3
Department of Electronic & Electrical Engineering
Sending data/instructions to the LCD
Data sent to the LCD controller can be either an:
Instruction (if RS is high) Data (character) (if RS is low)
To send a value (Data/Instruction) to the LCD
Set RS appropriately Put value onto lines D4-7 Strobe E (low high low)
Department of Electronic & Electrical Engineering
LCD Instructions (RS high) --- examples:
Clear LCD Position the cursor Set direction of cursor Set address of cursor Set 4/8 bit mode Set single / two line mode More . . .
Department of Electronic & Electrical Engineering
Display Data RAM (DDRAM)
Characters are stored by the HD44780 in Display data RAM (DDRAM)
This has a capacity of 80 characters (bytes).
DD RAM address is the position of the cursor
The DD RAM address layout for 2 line display is.
Department of Electronic & Electrical Engineering
Initializing the device.
If you are lucky the device will initialize itself on power up.
However this will only happen if some conditions are met (e.g. time to go from zero to full power).
It is best to do a full software reset . . . . makes sure the device is initialized properly.
Department of Electronic & Electrical Engineering
Reset sequence of LCD (see lcd_init).
Wait for about 20mS Send the first init value (0x30) Wait for about 10mS Send second init value (0x30) Wait for about 1mS Send third init value (0x30) Wait for 1mS Select bus width (0x20 for 4-bit) Wait for 1mS
Department of Electronic & Electrical Engineering
8 8bit version
Department of Electronic & Electrical Engineering
Switching to 4 bit Mode
We want to use 4bit mode. But controller starts in 8 bit mode!
We can switch to 4bit mode by sending
B'0010000' ; DL=0 sets 4 bit mode (note D0-3 can be zero).
Department of Electronic & Electrical Engineering
4 Bit mode
Once in 4 bit mode we can send an 8 bit instructions as 2 nibbles.
High nibble first. See routine lcd_send_w in the example code
Department of Electronic & Electrical Engineering
Writing characters to the LCD.
Each character be represented by a byte of data Each location on the display has an address. The controller has a cursor (address of the next character to be
written) We write a character to the display by
Setting RS high Put character code on data lines Strobe E
The cursor is moved ready for the next character.
Character codes.
Department of Electronic & Electrical Engineering
Example program lcd4bitHello.asm
Example that displays Hello on the LCD display.
Initializes the LCD Clears the LCD Sends 'H' 'e' 'l' 'l' 'o'
Department of Electronic & Electrical Engineering
Demo: lcd4bitHelloWorld.asm
Department of Electronic & Electrical Engineering
Screen Configurations
There are various LCD screen sizes. Common ones are
8X1 (one row of 8 characters) 16x1 16x2 20x2 20x4
The driver uses an address to define the position of a character.
The location of an address on the display depends on the device.
Some 16x1 devices behave differently from others!!!
Department of Electronic & Electrical Engineering
The PC 1601A 16x1 LCD display
From the controllers point of view it is a 2 line device.
The first 8 characters are on line 1 The second 8 characters are on line 2
Each line can have 40 characters (only 8 displayed) There are display shift operations which use this feature.
Department of Electronic & Electrical Engineering
Addresses of characters for PC 1601A
The second 8 characters start at address 40!!
This is because the connections to the controller are like a second line with 40 characters per line!!!!!
Department of Electronic & Electrical Engineering
Solution to the exercise
To send characters to the second 8 locations
Send a instruction to set the cursor address to 40
Send more characters
Department of Electronic & Electrical Engineering
Set cursor address instruction.
Department of Electronic & Electrical Engineering
HD44780 driving a 2 line LCD
Department of Electronic & Electrical Engineering
2 rows mapped onto 1 row.