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.

[SOLVED] hyper terminal and 8051 communication issues

Status
Not open for further replies.

pvk_vicky2000

Newbie level 3
Joined
Jul 13, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,318
hello friends i am a newcomer to 8051 programming
i cannot program in assembly
only C
i have written a code which would take input from keyboard(on pc) and display the characters on lcd connected to an 8051 uc

here are the key snippets of the code
*************************

void USART_Write_String ( unsigned char *str ){

while( *str ){
SBUF=*str++;
while(!TI);
TI=0;
} return;
}



unsigned char USART_Read_A_Char ( void )
{
unsigned char ch;
while(!RI);
ch = SBUF;
RI = 0;
return ch;
}



unsigned char *string1="hello pc\0";
unsigned char *string2="send the data\0";
unsigned char *test="I AM ALIVE\0";
unsigned char ch[2];
USART_Init_9600(); /*for initialization of uart sets ti ri tcon scon values
Lcd_Init(); /*lcd initialzation
SenStringToLcd(1,test); /*displays on lcd
USART_Write_String (string1); /*displays on hyper terminal
while(1)
{
USART_Init_9600();
USART_Write_String (string2);
ch[1]=USART_Read_A_Char();
ch[2]= '\0';
Delay(500);
SenStringToLcd(2,ch);
Delay(500);




void SenStringToLcd ( unsigned char lineNo, unsigned char *lcdStr ){

if (lineNo==1){
SendCommand(0x80);
while ( *lcdStr ){
SendData(*lcdStr++);
}
}
else if (lineNo==2){
SendCommand(0xC0);
while ( *lcdStr ){
SendData(*lcdStr++);
}
}
else {
}
return;
}


HERE's the problem


i get "hello pc send the data" on hyper terminal
iget "i am alive" on my lcd
when i type any character the send any data again appears conforming that the uc has accepted the data but nothing appears on my lcd where have i gone wrong.
i attached the entire code just in case
 

Attachments

  • New WinRAR ZIP archive.zip
    2.6 KB · Views: 102

you are receiving the data from hyper-terminal ok then you should convert that data in to ascii and display that data
because the received data will be in hex format
 
err... does anyone have the code for hex to ascii conversion i used a more rudimentary appproach 30=0 31=1 and so on it seems stupid
an algorithm might be a lot easier
 

//---------------------------------------------------------------------------//
// Function : convert_asciil() //
// Parameters : //
// Input : number to be converted //
// Output : returns //
// Description : Routine converts number to ascii //
//---------------------------------------------------------------------------//


unsigned char convert_ascii(unsigned char temp)
{

return((unsigned char)(temp>=0x0a)?(temp+0x37):(temp+0x30));

}
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top