Write A Program For Interfacing The 16x2 LCD MODULES Aim
Write A Program For Interfacing The 16x2 LCD MODULES Aim
Write A Program For Interfacing The 16x2 LCD MODULES Aim
Aim:
Write a program for interfacing the 16x2 lcd module
Hardware requirements:-
1. UTS-MS-KIT-M7.
2. A serial cable,9 pin cable wired one to one from female connector to male
connector.
3. PC with serial port.
4. 5V adopter.
Software requirements:-
1. UTS EDS or Kiel evaluation software.
2. Flash Magic.
Experimental procedure:
1. Open the KEIL IDE and create a new microvision project from Project menu and
save it in a folder.
2. Goto File menu and create a new document, write C code in that document, save
it in above created folder and add it to source group1 which is in target folder.
3. Goto Flash menu and click on configure flash tools.
- Click on output menu
i. Select create hex file option
ii. Set oscillator frequency = 11.0592MHz
4. Goto Project -> build target, then Hex file will be created.
5. Open Flash magic to download into the micro controller.
Settings:
COM Port : COM1
Baud Rate : 9600
Device : 89V51RD2
Interface : None (ISP)
Theory:-
LCDs can add a lot to your application in terms of providing an useful interface
for the user, debugging an application or just it a “professional” look. LCDs can be added
quite easily to an application and use as few as three digital output pins for contr The
most common connector used for the LCDs is 16pins in a row.
• In the Kit 8 bit mode is configured.
• R/S is controlled by P3_5 of the microcontroller.
• R/W is permanently grounded to make it in always write mode to LCD.
• Data Bus are connected to microcontroller Buffered Data Bus.
While there are secondary considerations and modes, deciding how to send the
data to the LCD is most critical decision to be made for an LCD interface application.
Eight bit mode is best used when speed is required in an application and at least ten I/O
pins are available. Four bit mode requires a minimum of six bits. To wire a
microcontroller to an LCD in four bit mode, just the top four bits (DB4- 7) are written to.
The "R/S" bit is used to select whether data or an instruction is being transferred between
the microcontroller and the LCD. If the Bit is set, then the byte at the current LCD
"Cursor" Position can be read or written. When the Bit is reset, either an instruction is
being sent to the LCD or the execution status of the last instruction is read back (whether
or not it has completed).
C SOURCE CODE
//MEMORY MAPPING
void ClrLcd(void);
void Delay(unsigned int duration);
void configlcd(void);
void lcdcommand(unsigned char value);
void lcddata(unsigned char value);
void putchar(unsigned char row,unsigned char col,unsigned char t);
void putstring(unsigned char row,unsigned char col,unsigned char *string);
void lineclear(unsigned char line);
void lineclear(unsigned char line);
sbit rs =P3^5;
// 8255 intialization
Delay(50);
ptr = Cs82551Control;
*ptr = 0x82;
// LCD intialization
ClrLcd();
configLcd();
Delay(15);
rs=1;
mes="WELCOME TO DEMO";
ptr = CsLCD;
ClrLcd();
while(1)
{
putstring(1,0,mes);
putstring(2,0,mes);
lineclear(1);
lineclear(2);
}
while(1);
}
//FUNCTIONS
//DELAY FUNCTION
Embedded Systems Design Lab Dept of ECE
MREC
Exp No: 5 Interfacing 16x2 LCD(8051) Page No : 46
rs=1;
Delay(15);
*lcd_pointer = value;
}
//Function For Giving Single Character To The Exact Position Of The Lcd
lcdcommand(row+col);
lcddata(t);
}
void ClrLcd(void)
{
rs=0;
*lcd_pointer = 0x01;
Delay(15);
rs=1;
}
}
//FUNCTION FOR CLEARING THE EXACT LINE IN THE LCD
switch(line)
{
case 1:row=0x80;
break;
case 2:row=0xc0;
break;
}
for(l=0;l<16;l++)
{
lcdcommand(row+l);
lcddata(' ');
}
}
Results/Discussion:
After programming the code into the microcontroller just reset the
microcontroller and put it in the run mode. We can observe display on the LCD.