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.

AT89c55 LCD interfacing 4 bit mode to port P0

Status
Not open for further replies.

tahertinu

Member level 4
Member level 4
Joined
Jun 11, 2011
Messages
74
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Ahmedabad
Activity points
1,752
hello, i am having problem interfacing 16x2 LCD with 89c55 controller i have used P0.4 to P0.7 as data and P2.0 and P2.1 as RS and EN respectively. I have connected 10K pull-up resistor with P0.but still i am not able to run on Hardware. Proteus run the code successfully. please tell me where I am Wrong?

CODE:
#include <regx55.h>
//*******************
//Pin description
/*
P2.4 to P2.7 is data bus
P1.0 is RS
P1.1 is E
*/
//********************

// Defines Pins
sbit RS = P2^0;
sbit E = P2^1;

//Function declarations
void cct_init(void);
void delay(int);
void lcdinit(void);
void writecmd(int);
void writedata(char);
void writeString(unsigned char *);
void ReturnHome(void);

void cct_init(void)
{
P0 = 0x00; //not used
//P1 = 0x00; //not used
P2 = 0x00; //used as data port
//P3 = 0x00; //used for generating E and RS
}

void delay(int a)
{
int i;
for(i=0;i<a;i++); //null statement
}

void writedata(char t)
{
RS = 1; // This is data

P0 &= 0x0F; // Make P2.4 to P2.7 zero
P0 |= (t&0xF0); // Write Upper nibble of data

E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);

P0 &= 0x0F; // Make P2.4 to P2.7 zero
P0 |= ((t<<4)&0xF0);// Write Lower nibble of data

E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);
}


void writecmd(int z)
{
RS = 0; // This is command

P0 &= 0x0F; // Make P2.4 to P2.7 zero
P0 |= (z&0xF0); // Write Upper nibble of data

E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);

P0 &= 0x0F; // Make P2.4 to P2.7 zero
P0 |= ((z<<4)&0xF0);// Write Lower nibble of data

E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);
}
void writeString(unsigned char *s)
{
while(*s)
writedata(*s++);

}
void lcdinit(void)
{
///////////// Reset process from datasheet /////////
delay(15000);

P0 &= 0x0F; // Make P2.4 to P2.7 zero
P0 |= (0x30&0xF0); // Write 0x3

E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);

delay(4500);

P0 &= 0x0F; // Make P2.4 to P2.7 zero
P0 |= (0x30&0xF0); // Write 0x3

E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);

delay(300);

P0 &= 0x0F; // Make P2.4 to P2.7 zero
P0 |= (0x30&0xF0); // Write 0x3

E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);

delay(650);

P0 &= 0x0F; // Make P2.4 to P2.7 zero
P0 |= (0x20&0xF0); // Write 0x2

E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);

delay(650);

/////////////////////////////////////////////////////
writecmd(0x28); //function set
writecmd(0x0c); //display on,cursor off,blink off
writecmd(0x01); //clear display
writecmd(0x06); //entry mode, set increment
}

void main()
{
cct_init(); //Make all ports zero
lcdinit(); //Initilize LCD

writeString("Hello World");
}

please help me out
 

If it's running in proteus. I think programming side it is good.
1. Check your hardware connections are quite good?
2. Another possibility could be, in proteus you don't have to connect external crystal. It works good in proteus, without using crystal.
If you are using external crystal, make sure your crystal works good and connected properly. This is the common problem when all hardware connections are good.
3. Adjust the contrast of the LCD. This is also common possibility.

Best wishes :)
 
If it's running in proteus. I think programming side it is good.
1. Check your hardware connections are quite good?
2. Another possibility could be, in proteus you don't have to connect external crystal. It works good in proteus, without using crystal.
If you are using external crystal, make sure your crystal works good and connected properly. This is the common problem when all hardware connections are good.
3. Adjust the contrast of the LCD. This is also common possibility.

Best wishes :)

how to check crystal?
 

If your are sure about hardware connections. and if u have any extra crystal. try to replace ..
Below replacing, In your program, you haven't defined any configuration and also no oscillator configuration bits.
I don't have experience in AT89c55 controller. So please check it.
 

Are there any spare pins available on the micro. Connect an LED to a spare pin and turn it on in the beginning of your code. If it comes on you
know your code is at least running.
 

i also encontered same problem during lcd interfacing which i later found out that bread board connections are not relaible ,signals may ride over one another .Solder the wires with lcd pins and then make connections, it will surely work :) *be careful during soldering it may damage your lcd *
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top