Anda di halaman 1dari 5

LCD interface with AT89C2051

By Sandip Nair sandipnair06@yahoo.com sandipnair.hpage.com

Aim: - In this documentation we would look after the interface of the LCD module JHD 162A (2x16 character display LCD) with AT89C2051. Circuit diagram: -

Figure1. LCD interface diagram with AT89C2051 Theory: - The LCD module has the following pins 1) Pin 1: VSS (Ground) 2) Pin 2: VCC (+5V supply) 3) Pin 3: LCD contrast adjustment 4) Pin 4: RS (instruction or data selection) 5) Pin 5: R/W (Read / write selection) 6) Pin 6: Enable 7) Pin 7 to Pin 14: DB0 to DB7 (data bits) 8) Pin 15: LED+ 9) Pin 16: LEDAccording to the data sheet as soon as the circuit is powered on, the microcontroller should wait for 15ms for display. Sequence of execution for 8051: 1) Command/ data 2) Clear RS / set RS 3) Clear R/W 4) Set E 5) Delay 6) Clear E 7) Delay 8) Go to step one OR 1) Check if the display is busy

2) Command/ data 3) Clear RS / set RS 4) Clear R/W 5) Set E 6) Clear E 7) Go to step one Initialization sequence: 1) 0x38 2) 0x0E 3) 0x01 4) 0x06 Command to LCD Instruction Register 1 Clear display screen 2 Return Home 4 Decrement cursor (shift cursor to left) 5 Increment cursor (shift cursor to right) 6 shift display right 7 shift display left 8 Display off, cursor off A Display off, cursor on C Display on, cursor off E Display on, cursor blinking F Display on, cursor blinking 10 Shift cursor position to left 14 Shift cursor position to right 18 Shift the entire display to the left 1C Shift the entire display to the right 80 Force cursor to the beginning of 1st line C0 Force cursor to the beginning of 2nd line 38 2 lines and 5 x 7 matrix
Program: // program for LCD interface to display welcome Sandip nair in two //different lines ORG 0x0000; RS EQU P3.4; RW EQU P3.5; EN EQU P3.7; // display 15ms wait CLR TR0; CLR TF0; MOV TL0, #0x00; MOV TH0, #0xCA; MOV TMOD, #0x01; SETB TR0; D1: JNB TF0, D1; CLR TF0; CLR TR0; ACALL INI_LCD;

MOV A, #0x57; // ACALL DISPLAY; MOV A, #0x65; ACALL DISPLAY; MOV A, #0x6C; ACALL DISPLAY; MOV A, #0x63; ACALL DISPLAY; MOV A, #0x6F; ACALL DISPLAY; MOV A, #0x6D; ACALL DISPLAY; MOV A, #0x65; ACALL DISPLAY; MOV A, #0xC0; ACALL CMD; MOV A, #0x53; ACALL DISPLAY; MOV A, #0x61; ACALL DISPLAY; MOV A, #0x6E; ACALL DISPLAY; MOV A, #0x64; ACALL DISPLAY; MOV A, #0x69; ACALL DISPLAY; MOV A, #0x70; ACALL DISPLAY; MOV A, #0xFE; ACALL DISPLAY; MOV A, #0x6E; ACALL DISPLAY; MOV A, #0x61; ACALL DISPLAY; MOV A, #0x69; ACALL DISPLAY; MOV A, #0x72; ACALL DISPLAY; MOV A, #0cd; ACALL DISPLAY; L1: SJMP L1; INI_LCD: MOV A, #0x38;// 2 lines and 5x7 matrix ACALL CMD; MOV A, #0x0C;//display on cursor off ACALL CMD; MOV A, #0x06;//increment cursor ACALL CMD; MOV A, #0x01;//clear display ACALL CMD; MOV A, #0x80;//cursor position ACALL CMD; RET; CMD: CALL WAIT;

MOV P1, A; CLR RS; CLR RW; SETB EN; CLR EN; RET; DISPLAY: CALL WAIT; MOV P1, A; SETB RS; CLR RW; SETB EN; CLR EN; RET; WAIT: SETB RW; // checking for wait pin in lcd CLR RS; L2: CLR EN; MOV P1, #0xFF; SETB EN; JB P1.7, L2; //check for busy pin CLR EN; RET; END;