8-Bit Mode LCD interfacing with 8051
As discussed in the previous section [ look here ] ,here providing the circuits diagram and the code including Proteus simulation file .
Controller - Atmel 89s52
Copmiler - Keil U-Version4
Simulator - Proteus 7.6
As discussed in the previous section [ look here ] ,here providing the circuits diagram and the code including Proteus simulation file .
Controller - Atmel 89s52
Copmiler - Keil U-Version4
Simulator - Proteus 7.6
Author - Gireesh Kumar K.S
Email - thannara123@gamil,com
Mob - 9447825107
C- Code for 89S52
#include <REGX51.H>
sfr lcd_dat = 0xA0;
sbit rs = P3 ^ 0; //register select pin
sbit en = P3 ^ 1; //enable pin
void delay(unsigned int msec)
{
int i, j;
for (i = 0; i < msec; i++)
for (j = 0; j < 1275; j++);
}
void lcd_strobe()
{
en = 1;
delay(1);
en = 0;
}
void lcdcmd(unsigned char gk)
{
lcd_dat = gk;
rs = 0;
lcd_strobe();
}
void lcd_Ini()
{
lcdcmd(0x38);
delay(30);
lcdcmd(0x0c);
delay(10);
lcdcmd(0x06);
delay(10);
lcdcmd(0x01);
delay(10);
}
void lcd_data(unsigned char gk)
{
lcd_dat = gk;
rs = 1;
lcd_strobe();
}
void string(const char *q)
{
while (*q) {
lcd_data(*q++);
}
}
void main()
{
P2 = 0x00;
P3 = 0x00;
lcd_ini();
string("Hello world ");
lcdcmd(0xc0);
string("Testing "); // test display
lcdcmd(0xc9);
lcd_data(58); // direct entry display
while (1) {
} // for endeless
}
Download here the full project including Proteus file
Download
sfr lcd_dat = 0xA0;
sbit rs = P3 ^ 0; //register select pin
sbit en = P3 ^ 1; //enable pin
void delay(unsigned int msec)
{
int i, j;
for (i = 0; i < msec; i++)
for (j = 0; j < 1275; j++);
}
void lcd_strobe()
{
en = 1;
delay(1);
en = 0;
}
void lcdcmd(unsigned char gk)
{
lcd_dat = gk;
rs = 0;
lcd_strobe();
}
void lcd_Ini()
{
lcdcmd(0x38);
delay(30);
lcdcmd(0x0c);
delay(10);
lcdcmd(0x06);
delay(10);
lcdcmd(0x01);
delay(10);
}
void lcd_data(unsigned char gk)
{
lcd_dat = gk;
rs = 1;
lcd_strobe();
}
void string(const char *q)
{
while (*q) {
lcd_data(*q++);
}
}
void main()
{
P2 = 0x00;
P3 = 0x00;
lcd_ini();
string("Hello world ");
lcdcmd(0xc0);
string("Testing "); // test display
lcdcmd(0xc9);
lcd_data(58); // direct entry display
while (1) {
} // for endeless
}
Download here the full project including Proteus file
Download