Hello!
Not at all, and I don't understand your code either. What I understand is that
you get a string if data is ready, and copy it into str. What for?
But anyway you can operate some factorization of your code. Writing \r\n is
in bothecased (i.e. doesn't depend whether data is ready or not). And delay
does not depend on it either.
So your code here
Code:
while(1){
if(UART1_Data_Ready() == 1){
UART1_Read_Text(st, ";", 255);
UART1_Write_Text(st);
strcpy(str,st);
UART1_Write_Text("\r\n");
Delay_ms(1000);
}
else{
UART1_Write_Text(str);
UART1_Write_Text("\r\n");
Delay_ms(1000);
}
}
could be rewritten as:
Code:
while(1){
if(UART1_Data_Ready() == 1){
UART1_Read_Text(st, ";", 255);
UART1_Write_Text(st);
strcpy(str,st);
}
else{
UART1_Write_Text(str);
}
UART1_Write_Text("\r\n");
Delay_ms(1000);
}
Dora