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.

16x4 lcd busy flag not working

Status
Not open for further replies.

embpic

Advanced Member level 3
Joined
May 29, 2013
Messages
742
Helped
80
Reputation
160
Reaction score
77
Trophy points
1,308
Location
india
Activity points
5,213
hello frnds
i am using p89v51rd2 controller and keil compiler.
i am getting problem in busy flag . till now i used to use delay but it is not that much efficient so help me to use busy flag in 16x4 lcd. i tried but not working
and my code is
Code:
sbit rs=P1^0;							 
sbit rw=P1^1;
sbit E=P1^2;
sbit d4=P1^4;
sbit d5=P1^5;			  
sbit d6=P1^6;
sbit lcd_st=P1^7;


void init_lcd()
{
	delay(15);
	command_write(0x03);
	delay(5);

	command_write(0x03);
	delay(5);

	command_write(0x03);
	delay(5);

	command_write(0x02);
	delay(5);

	command_write(0x28);
	delay(5);
	
	command_write(0x01);
	delay(5);

	command_write(0x0c);
	delay(5);
}

void data_map(unsigned char ds)
{
unsigned char ab;
	ab=ds;
	P1=P1&0x0f;
	ab=ab&0xf0;
	P1=ab|P1;
}


void command_write(unsigned char c_dt)
{
	lcd_status();
	rs=0;
	rw=0;
	data_map(c_dt);
	enable();
	lcd_status();
	rs=0;
	rw=0;
	c_dt=c_dt<<4;
	data_map(c_dt);
	enable();	
	
}


void data_write(unsigned char d_dt)
{
	lcd_status();
	rs=1;
	rw=0;
	data_map(d_dt);
	enable();
	lcd_status();
	rs=1;
	rw=0;
	d_dt=d_dt<<4;
	data_map(d_dt);
	enable();
}

void lcd_status()
{
	unsigned char temm;
	E = 0;
	lcd_st = 1;
	rs = 0;
	rw = 1;
	do
	{
		enable();
	}
	while(lcd_st==1);
	rw = 0;
	E = 0;
}

void delay (unsigned int val)
{
unsigned int n,m;
	for(n=0;n<val;n++)
		for(m=0;m<=120;m++);
}

void enable()
{
	E	=1;
	delay_us(15);
	E = 0;
}

void print(unsigned char *ptr,unsigned char addr)
{
	command_write(addr);
//	lcd_status();
	while(!(*ptr=='\0'))
	{
		data_write(*ptr++);
//		lcd_status();
	}
}

please correct my code.

thanx...
 

I think for initiation of LCD in 4 bit mode you need to give some additional command in lcd_init
Plz refer the datasheet. ...
Ismail
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top