Hi, I am trying to receive data on a PIC coming from a LCD screen connected with rs232. The data is only right sometimes. These are the functions I am having trouble with. Thanks
Code:
unsigned int16 ReceiveResponse()
{
unsigned int16 i=0;
memset(lcd_rx_msg,0,sizeof(lcd_rx_msg));
while(i<65535)
{
lcd_rx_msg[i] = fgetc(LCDSTREAM);
if(lcd_rx_msg[i] == 0X0D)
break;
i++;
}
return i;
}
unsigned int8 LCDGetVar(unsigned int8 var)
{
fprintf(LCDSTREAM,"get i%u\r",var);
ReceiveResponse();
if(lcd_rx_msg[0] != '!')
{
if(lcd_rx_msg[0] != '>')
return lcd_rx_msg[0] - 0x30;
}
}