Receive interrupt flag (
RCIF) is not getting cleared even after reading the
RCREG (several times!). Because of this I could not receive further data. How to get rid of this problem?
How do you know that RCIF isn't getting cleared? Because your perfect program won't run and the only possible explanation is that the hardware must be wrong?
As m.Alin said, a overrun error requires complete resetting of the receiver, but that can't happen due to receiving a single character. Set up a test so that you can send single characters to the PIC and see how it handles them. Then you can walk thru your code and see what it's messing up.
Are you using interrupts? If so, there are several things you could have messed up in the interrupt routine independent of the UART. To see something work initially, write a simple polling loop that looks for RCIF, reads RCREG, and writes the result to a port register or something. Have it toggle a pin everytime is receives a character so you can tell if that is happening at the expected time.
Some likely errors are that you didn't set the bank correctly to access PIR1 or RCREG.