I am using PIC18F and currently trying to interface it with SIM900. I am using UART Rx interrupt. ISR is working correctly but I wonder how to get data in main loop. Lets say :
#pragma interrupt hi_prioriint
void hi_prioriint(void)
{
if(PIR1bits.RCIF==1)
{
Rx = ReadUSART(); //store the received byte in Rx
}
}
Now I want to use Rx
in main loop. For example, if I send AT
command then I need to check if I received OK
or ERROR
from SIM900. (For the time being I am just testing it with a single byte and will convert it later into receiving strings because response from the SIM900 is in string form)
Example:
putrsUSART("AT\r"); //sending AT command
delay(500) //delay of 500ms
if(strcmp(Rx,"OK")==0) //checking the response
{
//if received OK then proceed further
}
So how to use RX data of ISR in main loop.? Please guide.