Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help wif project sourcecode

Status
Not open for further replies.

Desperrado

New Member
Im one day away from my deadline and my project isnt working!!i realli nid help.I have connected a Cygnal C8051F005 to a farnell lcd.My connections are : LCD pin 7 to 14 to c8051 port 1(p1.6 to p 1.1) and i nid to show the words " Height : " without the quotes.The lcd still cant work after i inputted the program.here is my program.Pls correct my program.The datasheet for the lcd is **broken link removed** reply to alone_againSQ@hotmail.com.I really appreciate any help at all and many thanks to those reading the post.


#include<c8051f000.h>



sbit E =P0^4;
sbit RS =P0^6;
sbit RW =P0^7;

void delay(unsigned a,unsigned b)
{
TMOD = 0x01;
TR0 = 0;
TF0 = 0;
TH0 = a;
TL0 = b;
TR0 = 1;
while(TF0==1);
}

void delay_1()
{
int a;
TMOD = 0x01; // Timer Mode Register
for(a=0;a<50;a++)
{
TH0 = 0x00; // Timer 0 High Byte
TL0 = 0x00; // Timer 0 Low Byte
TF0 = 0;
TR0 = 1;
while(TF0==0)
{
TR0 = 0;
}

}
}

void delay_2(unsigned int x)
{
while(x!=0)
{
x--;
}
}

void strobe()
{
E = 1;
delay(0xFF,0x69);
E = 0;
delay(0xFF,0x69);
}

void data_write(unsigned char x)
{
RS = 0;
RW = 0;
P1 = x;
strobe();
}

void control_write(unsigned char x)
{
RS = 1;
RW = 0;
P1 = x;
strobe();
}

void display_init()
{
XBR0 = 0x00;
XBR1 = 0x00;
XBR2 = 0x40;
PRT1CF=0xFF;
PRT0CF=0xFF;
delay(0x8A,0x00);
RS = 0;
RW = 0;
P1 = 0x38;
strobe();
delay(0xFF,0x00);
RS = 0;
RW = 0;
P1 = 0x0E;
strobe();
delay(0xFF,0x00);
RS = 0;
RW = 0;
P1 = 0x01;
strobe();
delay(0xFA,0x00);
RS = 0;
RW = 0;
P1 = 0x06;
strobe();
}




void main()
{
display_init();
control_write(0x80);
data_write(0x48);
delay(0xFF,0x00);



}
 
i see atleast two inconsistencies
Code:
void delay(unsigned a,unsigned b)
{
TMOD = 0x01;
TR0 = 0;
TF0 = 0;
TH0 = a;
TL0 = b;
TR0 = 1;
[b]while(TF0==1); [/b]
}
shouldn't it be :- while(TF0==0) . ?
then
Code:
void delay_1()
{
int a;
TMOD = 0x01; // Timer Mode Register
for(a=0;a<50;a++)
{
TH0 = 0x00; // Timer 0 High Byte
TL0 = 0x00; // Timer 0 Low Byte
TF0 = 0;
TR0 = 1;
[b]
while(TF0==0)
 {
 TR0 = 0;
 }
[/b]
}
}
the bolded part resets the the timer in the first loop itself. right.?
i think it should be
Code:
for(a=0;a<50;a++)
{
 ....
 while(TF0==0);
 TR0 = 0;
}
 
the lcd still cant work after i changed according to your help,and
data_write(0x48) is supposed to display the lettere "H"..i thought ill start wif something small at least get the lcd to display a letter 1st.however the lcd jus keep jumping..meaning the lcd's 1st row & 3th row(from top to bottom) keep jumping to all 4 rows,all the while displaying full dark characters on each row.

ill elaborate the lcd screen -> XXXXXXXXXX

XXXXXXXXXX



Then in will changed to -> XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
 
sorry its supposed to be XXXXX<-1st row

XXXXX<-3th row


then the lcd will change to XXXXX <-1st row
XXXXX <-2nd row
XXXXX <- 3th row
XXXXX <-4th row
 
n the parts of my program that are changed ->



void delay(unsigned a,unsigned b)
{
TMOD = 0x01;
TR0 = 0;
TF0 = 0;
TH0 = a;
TL0 = b;
TR0 = 1;
while(TF0==0);
}

void delay_1()
{
int a;
TMOD = 0x01; // Timer Mode Register
for(a=0;a<50;a++)
{
TH0 = 0x00; // Timer 0 High Byte
TL0 = 0x00; // Timer 0 Low Byte
TF0 = 0;
TR0 = 1;
while(TF0==0);
TR0 = 0;


}
}



I hope i got what you are teaching .
P.S the lcd still retains the "jumping"
 
the lcd still cant work after i changed according to your help,and
data_write(0x48) is supposed to display the lettere "H"..i thought ill start wif something small at least get the lcd to display a letter 1st.however the lcd jus keep jumping..meaning the lcd's 1st row & 3th row(from top to bottom) keep jumping to all 4 rows,all the while displaying full dark characters on each row.

ill elaborate the lcd screen -> XXXXXXXXXX

XXXXXXXXXX



Then in will changed to -> XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
 
ok.two more ..in the display_init()
modify
Code:
[b]RS = 1;[/b]
RW = 0;
P1 = 0x38;
strobe();
delay(0xFF,0x00);
[b]RS = 1;[/b]
RW = 0;
P1 = 0x0E;
strobe();
delay(0xFF,0x00);
[b]RS = 1;[/b]
RW = 0;
P1 = 0x01;
strobe();
delay(0xFA,0x00);
[b]RS = 1;[/b]
RW = 0;
P1 = 0x06;
strobe();
and the strobe fn:
Code:
void strobe()
{
[b]
E=0 ;
delay(0xFF,0x69);
[/b]
E = 1;
delay(0xFF,0x69);
E = 0;
delay(0xFF,0x69);
}
and main as
Code:
void main()
{
display_init();
control_write(0x80);
data_write(0x48);
delay(0xFF,0x00);
[b] while(1); [/b]
}
 
Last edited:
i have changed the parts that u advise me to change now my program is
void display_init()
{
XBR0 = 0x00;
XBR1 = 0x00;
XBR2 = 0x40;
PRT1CF=0xFF;
PRT0CF=0xFF;
delay(0x8A,0x00);
RS = 1;
RW = 0;
P1 = 0x38;
strobe();
delay(0xFF,0x00);
RS = 1;
RW = 0;
P1 = 0x0E;
strobe();
delay(0xFF,0x00);
RS = 1;
RW = 0;
P1 = 0x01;
strobe();
delay(0xFA,0x00);
RS = 1;
RW = 0;
P1 = 0x06;
strobe();
}

and



void strobe()
{

E = 0;
delay(0xFF,0x69);


E = 1;
delay(0xFF,0x69);
E = 0;
delay(0xFF,0x69);
}
 
plus


void main()
{
display_init();
control_write(0x80);
data_write(0x48);
data_write(0x47);
data_write(0x45);
data_write(0x48);
data_write(0x48);
while(1);

}

however the lcd stills retain its "jumping"
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top