I would like to know how to receive data without interrupts in the PIC18 controller. After setting the USART settings and baud rating, what things must be done so that USART receives properly without use of interrupts?

I'm using it in asynchronous mode. I have tested the transmission process successfully by checking the transmit bit in the USART TXSTAT register.

I have seen using a TRMT bit for tracking status of transmission in the EUSART register. But what can be used for receiving?

I did not see a similar pin in the RXSTAT register for asynchronous mode.

  • \$\begingroup\$ What do you mean by "out interrupt"? \$\endgroup\$
    – m.Alin
    Jul 24, 2014 at 9:42

1 Answer 1


The trick is that when interrupts are disabled the RCIF interrupt flag bit is still set, it just doesn't generate an interrupt. Reading a byte from the RCREG receiver data register clears the bit on most PIC18 chips I believe so that leaves at simple as:

if (PIR1.RCIF)        // We have a byte
   new_data = RCREG;  // Do something with it

Another thing is that if you get an overflow error because another byte arrives before you've read the first you'll also want something like the following to clear the error condition:

if (RCSTA.OERR)       // We had an overflow error
    RCSTA.CREN = 0;   // Clear the CREN bit to reset it
    RCSTA.CREN = 1;   // Re-enable continuous receive

The above will probably vary in syntax depending on the compiler you're using but hopefully gives you the general idea.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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