avr usart receive 0x00
Bobcat,
thanks for the info. But how to do this. doing only byte commands and i tried putting a buffer but can't say i know exactly what i'm doing here. the LED 2 is blinking but i don't think its the carry way. hope u can direct me to a link or a sample to do this buffer and parsing. thanks
unsigned short pos, i;
char lcdtext [41];
unsigned short lcd, buf ;
unsigned char buffer[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00};
char *tc1 ="on";
char *tc2 ="ot";
void main (){
TRISA =0;
PORTA =0;
Usart_Init (9600);
Lcd_Init (&PORTB);
i=0;
while (1)
{
if(Usart_Data_Ready ())
{
lcdtext = Usart_Read ();
lcd = Usart_Read ();
i++;
buffer[buf]= lcd;
buf++;
if (buf == tc1) portA.f0 = 1;
else if (buf == tc2) portA.f1 = 1;
if (i==40)
{
i=0;
Lcd_Cmd (LCD_RETURN_HOME);
for (pos=0;pos<40;pos++ )
{
Lcd_Chr_CP (lcdtext[pos]);
if (pos==16) Lcd_Cmd (LCD_SECOND_ROW);
}
Usart_Write('t');
}
}
}
}