As noted, over run and framing errors have to be explicitly cleared in software. They _should_ trigger the interrupt, but you might occasionally check for those error flags in your main loop occasionally as an extra protection. Check the data sheet for the recommended way to clear these errors. -Adam On 3/22/07, David wrote: > I have a UART set up on a PIC18F2520 to use the interrupt for receiving > incoming bytes from a data radio modem. > > Most of the time the UART receives bytes very reliably and then every > now and then it stops receiving. > > The RCIE interrupt is still enabled, the Global interrupt is still > enabled andthe RCIF flag has not been set. > > Sometimes I do notice the OERR has been set. I suspect that when there > is a lot of noise coming from the data radio that occasionally an > overrun error is occurring and this is stopping reception of further bytes. > > At present my interrupt reads RCREG and THEN checks for OERR and FERR. > ie... > > > rx_char = RCREG > if((OERR)||(FERR)) > { > rx_char = RCREG; > CREN = false; > CREN = true; > } > > else ..... > > Is this correct ? > > Or should I do something like this instead ? > > if(OERR) > { > CREN = false; > CREN = true; > } > > else if(FERR) > { > rx_char = RXREG; > } > else > { > rx_char = RCREG; > process..... > } > > It seems from the Microchip datsheet that maybe the second approach is > the correct way to handle the com errors ? > > Finally, do you ever place a check in your main code loop ? > ie. if(OERR) .. > Or is this unneccesary as the OERR and FERR will always be able to be > handled in the inerrupt routine ? > > In summary, I need to now the right way to handle com errors when using > receive interrupts so that the UART cannot get into a state where it > does not receive when RCIE is set and RCIF has been cleared. > > Thanks in advance for your assitance > > Regards > > David > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Moving in southeast Michigan? Buy my house: http://ubasics.com/house/ Interested in electronics? Check out the projects at http://ubasics.com Building your own house? Check out http://ubasics.com/home/ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist