Hey, Thanks a lot for your while(RCIF) tip. I'm already busy starting up my vmware session to make the change and test it. Exactly the type of things I was hoping for. Re. your FIFO tip? How do you implement this fifo? Quintin Beukes On Fri, Oct 9, 2009 at 5:17 PM, Harold Hallikainen wrote: > You don't specify which PIC you're using, but the UARTs tend to be > similar. From http://ww1.microchip.com/downloads/en/DeviceDoc/41350C.pdf, > we find: > > 16.1.2.4 Receive Interrupts > The RCIF interrupt flag bit of the PIR1 register is set > whenever the EUSART receiver is enabled and there is > an unread character in the receive FIFO. The RCIF > interrupt flag bit is read-only, it cannot be set or cleared > by software. > > So, the RCIF=3D0 does nothing since the bit is read only. As others have > pointed out, there is a small FIFO in the UART. Because of this, I'd > change the if(RCIF) to while(RCIF). This will loop the routine that pulls > data from the UART until it is empty. > > Finally, I like putting stuff from the UART ISR into a FIFO instead of a > linear buffer. In your non-interrupt code, you can pull data from the FIFO > and put it in the linear buffer for command interpretation at your > leisure. Putting data into the command interpreter buffer in the interrupt > requires the mainline code to act quickly on finding the end of command > before new data comes in and overwrites the command. Or, the command > interpreter could be in the ISR, but I like to keep them small and fast. > Of course, if the other end does not send a new command before getting a > response from this end, dropping directly into the linear buffer would > work fine. > > In a recent project (movie theater closed captioning receiver), I have > packets of data coming in at 10kbps. It takes a variable amount of time to > deal with the data (most of the time just sticking it in a linear array, > but at the end of a packet doing a CRC check and then acting on it if > good), so the amount of data in the FIFO between the ISR and the mainline > code grows and shrinks as required so nothing gets lost. > > Good luck! > > Harold > > > > >> >> =A0 =A0 if (RCIF) >> >> =A0 =A0 { >> >> =A0 =A0 =A0 =A0 char c =3D RCREG; >> >> >> >> =A0 =A0 =A0 =A0 SerialRecordCharacter(c); >> >> >> >> =A0 =A0 =A0 =A0 RCIF =3D 0; >> >> =A0 =A0 } >> > > > -- > FCC Rules Updated Daily at http://www.hallikainen.com - Advertising > opportunities available! > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist