pvk_vicky2000
Newbie level 3
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
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