I was getting problem every time when I used UART1_Write_Text("\r\n"); and Delay_ms(1000);.
This the flow of execution of this given code.
Code: Select all
void main(){
char str[256] = "0";
char st[256];
TRISC6_bit = 0; // Tx pin set as output
TRISC7_bit = 1; // Rx pin set as input
UART1_Init(9600); // Initialize the UART with a baud rate of 9600
Delay_ms(4); //Wait for UART to stabilize
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);
}
}
}
In this code, If I remove the UART1_Write_Text("\r\n") and Delay_ms(1000);, It will work.
can someone explain why this is happening, I want the same flow of execution like above code.
Regards,
Kumar