Hello all, I am using 8051 controller with UART working. I am generating interrupt for UART RX.
in main() I am sending one string to hyperterminal through UART TX and I can see it on Hyperterminal i.e my UART TX is working. I am sending one string to UART RX through hyperterminal and I can see it in my UART RX interrupt i.e my UART RX with interrupt is also working. I could establish the communication between hyperterminal on PC and UART_TX_RX on controller.
Now,My transmit code: 1. I am transmitting one string to hyperterminal from UART TX and I can see it on terminal say for example "ABC" 2. I am waiting for response from hypterminal say "123", using following loop 3. and when I get the required string I will come out of the loop
extern volatile unsigned char rx_buf[20; #define DETECTED_STR "123" Transmit_string("ABC"); while(strncmp((const char *)DETECTED_STR,(const char *)rx_buf,4)); Delay();
Now,My receive code:
volatile unsigned char rx_buf[20]; void sci0rx_isr(void) { rx_buf[index] = SCI0.RDR; SCI0.SSR.BIT.RDRF = 0; }
if I omit while loop I will get interrupt and string correctly. but I dont get the interrupt, if I add while loop. Wait there and do not proceed further until I get the required string.
ISR is at highest priority even then it can not interrupt while loop. Please provide the solution for that
What makes you think it is even safe to do a strcmp() while the interrupt is expected to add more characters to one of the two buffers used as parameters for strcmp()? How is the zero-termination handled?