kumarr123
Junior Member level 1
Hi,
I want output of this below code like- initially it print the whatever have the initial value, it will keep on printing until I entered the new integer, again it will keep on printing(old value ) value until I entered the new value and so on. This below code works well for single digit Integer(0-9), when I read integer greater than 10, first time it get stuck, second time I read same value it print wrong value.
I am using PIC18F67K40 micro-controller.
1) This is when I am reading single digit integer and printing the same:
2) This is when first time I am reading integer greater than 10 and try to print, but it get stuck:
3) This is when second time enter the same integer get gives wrong value:
Hope you understood the problem.
Regards,
Kumar
I want output of this below code like- initially it print the whatever have the initial value, it will keep on printing until I entered the new integer, again it will keep on printing(old value ) value until I entered the new value and so on. This below code works well for single digit Integer(0-9), when I read integer greater than 10, first time it get stuck, second time I read same value it print wrong value.
I am using PIC18F67K40 micro-controller.
Code:
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);
}
}
}
2) This is when first time I am reading integer greater than 10 and try to print, but it get stuck:
3) This is when second time enter the same integer get gives wrong value:
Hope you understood the problem.
Regards,
Kumar