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?
2 Answers
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.
the FERR bit must be read before reading the RCREG.
-
1\$\begingroup\$ Can you give us some more information, this currently does not meet our quality guidlines, can you give some information on what all needs to be set or the symptoms of this issue would be. \$\endgroup\$– KortukCommented Jul 16, 2012 at 14:04
CREN = 0; CREN = 1;
\$\endgroup\$