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.

Problem with LCD while displaying with 4 bit data transfer with 89s52

Status
Not open for further replies.

anboli

Full Member level 2
Joined
Mar 9, 2012
Messages
144
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
2,512
i interfaced the 2*16 lcd(Winstar PC-001 94V-) with 89s52 controller,

i got the displaying output while using the 8bit data transfer between them,

but im trying to reduce to 4bit, it getting problem and displaying some different data.

I send "ABCD" to LCD but it displaying 4T$ and so on...

i attached my program here, please anyone help me to solve this problem..

**********----------------------------------------***************

#include<at89x52.h>


sbit rs = P3^6;

sbit en = P3^7;


void delay(unsigned int count)
{
int i,j;
for(i=0;i<count;i++) // 100 ====> 1.5s && 1000 ====> 15s
for(j=0;j<1275;j++);
}

void lcd_command(unsigned char comm)
{
unsigned char temp_value;
temp_value = comm;
temp_value = temp_value & 0xf0;
P0 = temp_value;
P1 = temp_value;
rs=0;
en=1;
en1=1;
// rw=0;
delay(3);
en=0;
en1=0;
delay(50);
temp_value = comm << 4;
temp_value = temp_value & 0xf0;
P0 = temp_value;
P1 = temp_value;
en=1;
en1=1;
// rs=0;
// rw=0;
delay(3);
en=0;
en1=0;
}

void lcd_data(unsigned char disp)
{
unsigned char temp_value1;
temp_value1 = disp;
temp_value1 = temp_value1 & 0xf0;
P0 = temp_value1;
P1 = temp_value1;
rs=1;
rs1=1;
en=1;
en1=1;

// rw=0;
delay(3);
en=0;
en1=0;
delay(50);
temp_value1 = disp << 4;
temp_value1 = temp_value1 & 0xf0;
P0 = temp_value1;
P1 = temp_value1;
en=1;
en1=1;
// rs=0;
// rw=0;
delay(3);
en=0;
en1=0;
}

lcd_dataa(unsigned char *disp)
{
int x;
for(x=0;disp[x]!=0;x++)
{ //lcd_command(0x07);
lcd_data(disp[x]);
//delay(20);
}
}

void lcd_ini()
{ delay(3);
lcd_command(0x30);
delay(2);
lcd_command(0x30);
delay(1);
lcd_command(0x30);
delay(1);
lcd_command(0x20);
delay(1);
lcd_command(0x06);
delay(5);
lcd_command(0x01);
delay(5);
lcd_command(0x28);
delay(5);
lcd_command(0x0e);
delay(5);
lcd_command(0xc2);
delay(5);
}

void main()
{
P0 = 0x00;
P1 = 0x00;
P3 = 0x00;

lcd_ini();
lcd_data('A');
delay(300);

P0 = 0xff;
delay(300);
P0 = 0x00;

while(1)
{
lcd_command(0x01);
delay(10);

lcd_data(0x35);
delay(100);

lcd_dataa("ABCD");
delay(1000);

}
}

***********************----------------------------------********************
 

Hi
Here is a working code that i wrote for PIC18f252. Change the pins according to you settings.
 

Attachments

  • LCD display.h.txt
    1.4 KB · Views: 63
  • LCD display.c.txt
    2.5 KB · Views: 75

I don't know C but I imagine that the error is in these lines, I could not understand the logic here, to many temp_value1?

temp_value1 = disp << 4;
temp_value1 = temp_value1 & 0xf0;
P0 = temp_value1;
P1 = temp_value1;
 

Post your circuit

P0 = temp_value1;
P1 = temp_value1;

What is need to send same value to 2 ports??
 

thanks,
one port is interfaced with the lcd data lines and another port is interfaced with LED to check the data's whether sending correctly or not, so only,

and after the long struggle i got the output for this program.

- - - Updated - - -

thanks,
one port is interfaced with the lcd data lines and another port is interfaced with LED to check the data's whether sending correctly or not, so only,

and after the long struggle i got the output for this program.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top