[SOLVED] Issues in Lcd interfacing with 8051

Status
Not open for further replies.

Akshit Sharma

Newbie level 3
Joined
Jan 21, 2014
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
28
Hi,
I am interfacing a 16x2 LCD with AT89c51 microcontroller. Attached is the design file and c code for the same. I am getting a logic contention warning on proteus. I have checked my code many times but couldn't find anything. Please Help.
Thanks
code
Code:
#include <reg51.h>
sbit rs=P2^5;
sbit rw=P2^6;
sbit en=P2^7;
sbit busy=P3^7;
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void lcdready();
void delay();
void main()
{
	lcdcmd(0x38);
	lcdcmd(0x0C);
	lcdcmd(0x01);
	lcdcmd(0xC0);
	lcddata('H');
	lcddata('I');
	while(1);
}
void lcdcmd(unsigned char value)
{
	lcdready();
	P3=value;
	rs=0;
	rw=0;
	en=1;
	delay();
	en=0;
}
void lcddata(unsigned char value)
{
	lcdready();
	P3=value;
	rs=1;
	rw=0;
	en=1;
	delay();
	en=0;
}
void lcdready()
{
	busy=1;
	rw=1;
	rs=0;
	while(busy==1)
	{
		en=0;
	  delay();
	  en=1;
	}
}
void delay()
{
	unsigned int j;
  for(j=0;j<2550;j++);
}
 

Pins connected to LCD are not configured as output pins.
I have tried the same program using my name as the string. It works fine till AKS (in image below) but after that i get a logic contention. I tried configuring the port as output using 0x00 but still get the same error. If there's some other method, please let me know. Thanks
 

Try this code...
This code works fine even if i don't use p3=0x00; and p2=0x00; but the main purpose of using the busy bit is defeated. I was trying to get the busy bit into action. Can't i use the busy bit and get it going as well? Thanks.

- - - Updated - - -

I rearranged the original code a little by using P3=value after initializing RW and RS in both lcddata and lcdcmd functions. This reduced the number of logic contentions. But i still get one logic contention if I try writing anything after 'H' in the wire connecting D2 of LCD. Thanks

- - - Updated - - -

Problem solved. I used P3=0xFF i place of using busy=1 in lcdready() and the error was gone. Thanks for the help.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…