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.

send data or char 4m hyperterminal to lcd using 89c51

Status
Not open for further replies.
Did you check the half duplex? If it still doesn't work then your MAX232 circuit is damaged.

Try putting the uart receive code in interrupt routine.

thank you very very much jay for helping me
i got output on LCD but there is only one line i can see one LCD .
it should possible if i write more then one line and that is going to be display on lcd and automatically that LCD cursor will take next line ,and i can write unlimited char/word/sententious on lcd
 

After you write first line on lcd then you have to send lcd command 0xC0 so that next data is printed on line 2 and if you want to print again then clear the display and give lcd command 0x80 for first line and then it prints on line 1.
 
After you write first line on lcd then you have to send lcd command 0xC0 so that next data is printed on line 2 and if you want to print again then clear the display and give lcd command 0x80 for first line and then it prints on line 1.
that oxco can i directly give from hyperterminal or have add in main program?
and i got two world at a time.thats mean if i write in hyperterminal ronak then lcd is showing ronak#ronak .
 

Send some code like '1' and '2' from PC to MCU and write code such that if '1' is received 0x80 cmd is sent to lcd and if '2' is received 0xc0 cmd is sent to lcd.
 

Post your latest code. I will answer tomorrow.

#include <REGX51.H>
sbit rs= P3^5;
sbit rw= P2^1;
sbit en= P3^4;
////////////////////////////////////Delay////////////////////////////////////
void mdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
/// / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / L C D COMMAND////////////////////////////////////
void lcdcmd(unsigned char value)
{
P1=value;
rs=0;
rw=0;
en=1;
mdelay(1);
en=0;
}
void lcd_data(unsigned char value)
{

P1=value;
rs=1;
rw=0;
en=1;
mdelay(1);
en=0;
}
/////////////////////////////////STRING LCD////////////////////////////////
void string_lcd(unsigned char *ptr)
{
unsigned int h,j=0;
while(*ptr)
{
h++;
if(h<15)
{
lcd_data(*ptr++);
}
if(h>=15)
{

lcdcmd(0xC0+j);
lcd_data(*ptr++);
j++;
}
//mdelay(250);
//lcdcmd(0x18);
}
// *(ptr++);
}

//INITIALIZATION///////////////////////////////
void uart_init()
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}
/// / / / / / / / / / / / / / / / / / / / / / / / / / / / / L C D INITIALIZATION//////////////////////////////
void lcd_init()
{
lcdcmd(0x38);
//mdelay(250);
lcdcmd(0x0F);
//mdelay(250);
lcdcmd(0x01);
//mdelay(250);
lcdcmd(0x06);

} //mdelay(250);

void main()
{

unsigned char str2[100],*ptr;
unsigned int i;
ptr=str2;
uart_init();
lcd_init();

while(SBUF!=0x0D) //Checking if the enter is pressed or not
{
while(RI==0);
RI=0;
str2=SBUF;
i++;
}
str2='\0';
string_lcd(ptr);
// To display on LCD
for(i=0;i<6;i++)
{
lcd_data(str2);
}
while(1);
}
 

where is the code which checks if 16 characters are received and the code which checks if lcd line1 or line 2 has to be selected?
but i have confusion where that code will be add in program.
and i was add here some code if(h<15)
{
lcd_data(*ptr++);
}
if(h>=15)
{

lcdcmd(0xC0+j);
lcd_data(*ptr++);
j++;
 

You are checking if h>=15. also add if h >=31 lcd_cmd(0x80)
i was added this code but rightnow that another data didn't sow on lcd
h++;
if(h<15)
{
lcd_data(*ptr++);
}
if(h>=15)
{

lcdcmd(0xC0+j);
lcd_data(*ptr++);
j++;
}
if(h>=31)
{
lcdcmd(0x80);
lcd_data(*ptr++);
}
 

I see that you use j to increment the character position. You have done that for line 2 but not for line 1. when H is >= 31 then j should be set 0 and use lcd_cmd(0x80+j) and j++;

see if your lcd_cmd() function auto increments the position of character.
 

I see that you use j to increment the character position. You have done that for line 2 but not for line 1. when H is >= 31 then j should be set 0 and use lcd_cmd(0x80+j) and j++;

see if your lcd_cmd() function auto increments the position of character.
i was also try with this code void string_lcd(unsigned char *ptr)
{
unsigned int h,j=0;
while(*ptr)
{
h++;
if(h<15)
{
lcd_data(*ptr++);
}
if(h>=15 && h<=31)
{

lcdcmd(0xC0+j);
lcd_data(*ptr++);
j++;

}
if(h>31 && h<47)
{
mdelay(300);
lcdcmd(0x01);
lcd_data(*ptr++);
}
if(h>=47)
{
lcdcmd(0xC0+j);
lcd_data(*ptr++);
j++;
}
//mdelay(250);
//lcdcmd(0x18);
}
but i didn't get output.
here i can see 32 char is 100% clear but after 32char there is overwriting will be started.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top