Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] LCD interfacing with 8051

Status
Not open for further replies.

pravin b

Member level 5
Member level 5
Joined
May 20, 2012
Messages
85
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Location
Mumbai, India
Activity points
2,083
hello mates;

I have written the code for displaying characters on 16*2 LCD with 8051 in C language (in 8 bit mode);
however i could not see any output on my Proteus simulator.
I checked my code again and again, can i have your expert looks please...

thanks & regards,
Pravin B


here is code:::::::::

Code:
#include<REG51.H>

sbit rs=P0^0;							//rs connected to p0.0
sbit rw=P0^1;							//rw connected to p0.1
sbit en=P0^2;							//en connected to p0.2
sbit busy=P2^7;							//busy connected to p2.7

void delay(unsigned int count)			//delay subroutine
{
unsigned int i,j;
for(i=0;i<=count;i++)
	for(j=0;j<=1275;j++);
}

void ready()							//subroutine to check if lcd is busy
{
busy=1;									//make busy pin input
rs=0;									//rs=low
rw=1;									//rw=high
while(busy==0)							//check if busy flag is equal to 0
	{
	en=0;
	delay(2);
	en=1;
	}
}

void lcd_cmd(unsigned int value)		//sub. to write commands 
{
ready();
P2=value;
rs=0;
rw=0;
en=1;
delay(2);
en=0;
}

void lcd_data(unsigned int value)		//sub to write data
{
ready();
P2=value;
rs=1;
rw=0;
en=1;
delay(2);
en=0;
}

void lcd_init()							 //lcd initializtion
{
lcd_cmd(0x38);
lcd_cmd(0x0E);
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x80);
}

void main()
{
rs=0;									 //rs=output
rw=0;									 //rw=output
en=0;									 //en=output
P2=0x00;								 //port2=output

while(1)
	{
	lcd_init();								 //call lcd initializtion
	lcd_data('A');							 //send char A
	lcd_data('b');
	lcd_data('c');
	lcd_data('D');
	delay(50);
	}
}

 

u hav not grounded vss and vee and given +5v to vdd,first do it then report
 
hi pratzz,
I have applied the +5v to vdd and ground to VSS,VEE but still the result is same...their is no errors in code???? please confirm if for me...
 

i hav never used busy flag but otherwise your pgm luks ok.
but change port 0 to port 1 as port 0 requires pull up resistors,mayb perhaps tats the problem
 
no probs,there is option of helped me in the post.always click it if u find sum1's post useful
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top