LCD

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

The LCD display has two lines of characters, 16 characters per line.

Each character is composed of matrix of pixels size 5x8.

The matrix is controlled by Hitachi HD44780 controller, which performs all the
operations that are required to run the matrix.

Controller operation is done in accordance with the instructions it receives as described


below:
• DB0 - DB7, the 8 data bus lines, which perform read/write of data

• Vss, Vdd - Voltage supply pins

• R/W – Pin writing/reading to/from – LCD

• RS - Pin selects registers between command Register and Data


Register

• E - "Enabling" pin; when this pin is set to logical low, the LCD
does not care what is happening with R/W, RS, and the data bus
lines; when this pin is set to logical high, the - LCD is processing
the incoming data

• Vo - Pin for LCD contrast


LCD registers
The HD44780U controller has two 8-bit registers:

• Command register (CR) - the CR stores instruction codes,


such as display clear and cursor shift, and address
information for display data

Data register (DR) - the DR temporarily stores data to be


written into and temporarily stores data to be read from.
The DR is also used for data storage when reading data
from.

The choice between the two registers is made by the register


selector (RS) signal as detailed the following table:
RS R/W  

0 0 Sends a command to LCD

0 1 Read busy flag (DB7) and address counter (DB0 to DB6)

1 0 Sends information to LCD

1 1 Reads information from LCD


ALL character LCDS have

1.Eight (8) data pins D0-D7

2.VCC(apply +5 volt here)

3.GND(Ground this pin)

4.RS(Register select)

5.RW(read-write)

6.EN(Enable)

7.V0(Set LCD contrast)


Character LCD’s have a inbuilt controller called HD44780.

It is actually communicated with this controller in order to


display character on the LCD screen.

HD44780 must be properly handled and intialized before


sending data to it.

RS(Register select)
Register select selects the HD44780 controller register

It switches between command and data register


.Command register
.Data register
Command register
When commands are sent to LCD, the commands
go to command register and processed their.
When RS=0 command register is selected
Data register
When data is sent to LCD,it goes to data register
and processed their.
When RS=1 data register is selected
RW(READ-WRITE)
RW pin is used to read and write data to HD44780
data and command registers
When RW=1 -One can read data from LCD
When RW=0 -One can write data to LCD

ENABLE(ENABLE SIGNAL):
When register RS(command and data) is selected and set
RW(Read-write) and placed the raw value on 8-bit data lines
then the instruction is to be executed.

For this enable pin must be used.


Usually en=0 when we want to execute the instruction we
make it high en=1 for some milli seconds after this
again en=0
V0(Set LCD Contrast)
• This pin is used to set LCD display sharpness.

• Best way is to connect the output of the


potentiometer to this pin .

• Rotate the potentiometer knob forward and


backward to adjust the LCD contrast.
Instruction HEXVALUE

1.FUNCTION SET:8 BIT ,1 LINE 5*7 dots 0X30


2.FUNCTION SET:8 BIT ,2 LINE 5*7 dots 0X38
3.ENTRY MODE 0X06
4.DISPLAY OFF CURSOR OFF 0X08
5.DISPLAY ON CUSOR ON 0X0E
6.DISPLAY ON CURSOR OFF 0X0C
7.DISPLAY ON CURSOR BLINKING 0X0F
8.SHIFT ENTIRE DISPLAY LEFT 0X18
9.SHIFT ENTIRE DISPLAY RIGHT 0X1C
10.MOVE CURSOR LEFT BY ONE CHARECTER 0X10
11. MOVE CURSOR RIGHT BY ONE CHARECTER 0X14
12.CLEAR DISPLAY 0X01
13.FORCE CURSOR TO THE BEGINNING OF FIRST LINE 0X80
14.FORCE CURSOR TO THE BEGINNING OF 2ND LINE 0XC0
15.INCREMENT CURSOR 0X60
16.DECREMENT CURSOR 0X04
• LCD initialization

• The steps that has to be done for initializing the LCD


display is given below and these steps are common for
almost all applications.

• Send 38H to the 8 bit data line for initialization

• Send 0FH for making LCD ON, cursor ON and cursor


blinking ON.

• Send 06H for incrementing cursor position.

• Send 01H for clearing the display and return the cursor.
Sending data to the LCD
• The steps for sending data to the LCD module is given below. I
have already said that the LCD module has pins namely RS, R/W
and E.
• It is the logic state of these pins that make the module to determine
whether a given data input  is a command or data to be displayed.

• Make R/W low.

• Make RS=0 if data byte is a command and make RS=1 if the data
byte is a data to be displayed.

• Place data byte on the data register.

• Pulse E from high to low.

• Repeat above steps for sending another data.


• 12). To interface LCD with ARM processor-- ARM7TDMI/LPC2148. Write
and execute programs in C language for displaying text messages and
numbers on LCD
 
• #include <LPC214x.H> // Header file for LPC2148

• #include <STRING.H> // Header file for string manipulations

• #define LCD_DATA_PORT(DATA) (DATA << 16)

• // Pin from P1.16 to P1.23 configured as LCD data port.


• #define LCD_CMD_PORT(CMD) (CMD << 8)

• // Pin from P0.9 to P0.11 configured as LCD control signals.


• // Pin P0.11 configured as LCD enable signals. (high to low) ENABLE = 0x08;
• // Pin P0.10 configured as LCD read/write signals. (1-read, 0-write) RD_WR =
0x04;
• // Pin P0.9 configured as LCD register seletion signals.(1-data, 0-command)
RE_SE = 0x02;*/
•  
Void DELAY_1S(unsigned int n) // 1s delay
{
unsigned int i, j;
for(i=1; i<=n; i++)
for(j=0; j<=10000; j++);
}

void LCD_ENABLE() // Signal for LCD enable (high to low with 50ms)
{
IO0SET = LCD_CMD_PORT(0x08); // enable is set to 1
DELAY_1S(50); // 50ms delay
IO0CLR = LCD_CMD_PORT(0x08); // enable is cleared to 0
}

void LCD_DATA(unsigned int LDATA) // function to display the message


{
IO1PIN = LCD_DATA_PORT(LDATA); // moving the message to LCD data port
IO0CLR = LCD_CMD_PORT(0x04); // LCD to write mode (RD_WR = 0)
IO0SET = LCD_CMD_PORT(0x02); // LCD to data mode (RE_SE = 1)
LCD_ENABLE(); // Latching the data to display from buffer
}
void LCD_CMD(unsigned int LCMD) // function to configure the LCD
{
IO1PIN = LCD_DATA_PORT(LCMD); // moving the command to LCD data port
IO0CLR = LCD_CMD_PORT(0x04); // LCD into write mode (RD_WR = 0)
IO0CLR = LCD_CMD_PORT(0x02); // LCD into command mode (RE_SE = 0)
LCD_ENABLE(); // Latching the data to display from buffer
}

void DISPLAY_MESSAGE(unsigned char ADDRESS, char *MSG)


// Function to display a complete message
{
unsigned char COUNT,LENGTH;
LCD_CMD(ADDRESS);
LENGTH = strlen(MSG);
for(COUNT=0;COUNT<LENGTH;COUNT++)
{
LCD_DATA(*MSG);
MSG++;
}
}
int main( ) // Main function
{
IO0DIR =0x00000E00; // Pin from P0.9 to P0.11 configured as output pins.
IO1DIR =0X00FF0000; // Pin from P1.16 to P1.23 configured as output pins

// LCD initialize

LCD_CMD(0x38); // 8 Bit Mode, 2 Rows, 5x7 Font Style


LCD_CMD(0x0C); // Display Switch Command : Display on, Cursor on, Blink off
LCD_CMD(0x06); // Input Set : Increment Mode
LCD_CMD(0x01); // Screen Clear Command , Cursor at Home
 
DISPLAY_MESSAGE (0x80, " CHIPMAX DESIGN "); // Address of first row and message
DISPLAY_MESSAGE (0xC0, "0123456789ABCDEF"); // Address of second row and
message

while(1)
{
LCD_CMD(0x18); //to shift message to LEFT use code: 0x18,Right:0x1C,Stable:0x06
DELAY_1S(50);
}
}
 

You might also like