0
\$\begingroup\$

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?

PIC16F877A

\$\endgroup\$
1
  • 3
    \$\begingroup\$ You might have an Overrun Error in which case you should reset the receive logic: CREN = 0; CREN = 1; \$\endgroup\$ – m.Alin May 5 '12 at 11:25
1
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

the FERR bit must be read before reading the RCREG.

\$\endgroup\$
1
  • 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\$ – Kortuk Jul 16 '12 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.