Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature currently requires accessing the site using the built-in Safari browser.
void usrt_init()
{
SYNC=0;
BRGH=1;
SPEN=1;
CREN=1;
RX9=0;
SPBRG=10;
GIE=1;
PEIE=1;
RCIE=1;
RCIF=0;
}
PHP:void usrt_init() { SYNC=0; BRGH=1; SPEN=1; CREN=1; RX9=0; SPBRG=10; GIE=1; PEIE=1; RCIE=1; RCIF=0; }
Now, when any data is received then interrupt will occur. Then in interrupt service routine, if(RCIF==1) then collect the received value from RCREG register and clear RCIF. Choose SPBGR and BRGH value according to the baud rate requirement.
check datasheet of PIC16F87XA: page no 114. (hope you checked this since you already transmitted data)
or You can do it without interrupt also...In this case, you need to disable interrupt (RCIE=0); then you can check the status of RCIF periodically and if it become 1then clear it and read the received data from RCREG.
unsigned short i;
void main() {
// Initialize USART module (8 bit, 2400 baud rate, no parity bit..)
Usart_Init(2400);
do {
if (Usart_Data_Ready()) { // If data is received
i = Usart_Read(); // Read the received data
Usart_Write(i); // Send data via USART
}
} while (1);
}//~!