djc
Advanced Member level 1

Hi,
I wrote a code to send and receive the data serially. Application is such that, controller will send the data for particular received character. And will receive the string of characters and will update the 16 segment display. Now even if string of characters is received, interrupt will occur for every character received in string. I thought of taking a variable and increment it every time serial interrupt occurs. I have taken the serial interrupt in timer0 interrupt. Code is as follows,
Index is the variable which should be incremented each time serial interrupt occurs. However it's been increasing randomly. Please tell me what could be the issue.
I wrote a code to send and receive the data serially. Application is such that, controller will send the data for particular received character. And will receive the string of characters and will update the 16 segment display. Now even if string of characters is received, interrupt will occur for every character received in string. I thought of taking a variable and increment it every time serial interrupt occurs. I have taken the serial interrupt in timer0 interrupt. Code is as follows,
Code:
if(PIR1.RCIF==1){
PIR1.RCIF=0;
index++;
input_string[index]=RCREG;
MAX_CONTROL = 1;
UART1_Write(index+48);
Delay_ms(1);
MAX_CONTROL = 0;
RCREG=0;
}