bianchi77
Advanced Member level 4
- Joined
- Jun 11, 2009
- Messages
- 1,313
- Helped
- 21
- Reputation
- 44
- Reaction score
- 20
- Trophy points
- 1,318
- Location
- California
- Activity points
- 9,442
Guys,
I tried to accept character from serial,
but why the response is always NOT OK....I can see it's sending OK, with echo...
but ??
Code :
any ideas ?
Thanks
I tried to accept character from serial,
but why the response is always NOT OK....I can see it's sending OK, with echo...
but ??
Code :
Code:
unsigned char usart_receive( void )
{
/* Wait for data to be received */
while ( !(UCSR0A & (1<<RXC)) )
;
/* Get and return received data from buffer */
return UDR0;
}
usart_receive_str()
{
char line[50];
int i = 0;
while(1) {
line[i] = usart_receive();
if (line[i] == '\n') break;
i++;
}
line[i] = 0;
return line;
}
char_receive = usart_receive_str();
usart_pstr(char_receive);
if (strcmp(char_receive, "OK\r\n") == 0)
{
LCD_CLEAR;
lcd_string("OK!");
}
else
{
LCD_CLEAR;
lcd_string("NOT OK!");
}
any ideas ?
Thanks