Ian Cameron wrote: > > > I am working on two PIC16C63 projects. Both involve serial communication > > with other (Dallas) controller. Reception is interrupt driven (just one > > byte to receive). Both interrupt service routines are almost identical > > (interrupt enables, reception enables etc.) Nevertheless, while in one > > project communication is flawless, in other project reception stops at > > certain point and never happens again until program restarts (the rest > > of the program still working just fine). > > Will appreciate any advice. > > Is it possible that you are getting receiver overruns ? I had this > problem on a 16C63 where it would appear to lock up and would not > receive any more characters. > > The way I did it was to check RCSTA:FERR. If an overrun had > ocurred I read RCREG twice to empty the receive shift register, and > then reset the receiver by clearing RCSTA:CREN, and then setting it > again. > > Hope this helps. > > Cheers, Ian. Well, you are right. I've checked and I do get an overrun error (no framing errors though). I am trying to do everything to correct the problem (read buffer twice, reset the receiver, check one more time for data in a buffer), but anyway it finally ends up with overrun error and no reception. Will really appreciate if anybody can point to me where the problem is. Here is my interrupt routine (no other interrupts are enabled): ;=========================== RECEIVE_ROUTINE clrwdt ; btfss STATUS,RP0 ;Check bank goto NOTSET bcf STATUS,RP0 call DEVELOP_MESSAGE bsf STATUS,RP0 ;Restore bank retfie NOTSET call INTMAIN bcf STATUS,RP0 ;Restore bank retfie ;------------- DEVELOP_MESSAGE movwf TEMP_W ;Save context swapf STATUS,W movwf TEMP_STATUS ; bank1 bcf PIE1,RCIE ;for any reason - disable serial interrupt ; CHECK_OVERRUN bank0 btfss RCSTA, OERR ;If overrun - read twice, reset and get out goto READ_SERIAL_NORMAL CORRECT_SERIAL movf RCREG,W movf RCREG,W bcf RCSTA,CREN bsf RCSTA,CREN goto OUT_SER READ_SERIAL_NORMAL bank0 movf RCREG,0 ;read serial buffer movwf TEMPREBUF ;store in temp location ; ....... MESSAGE DEVELOPMENT ; OUT_SERIAL1 bank0 btfsc PIR1,RCIF ;If buffer is not empty - read again goto READ_SERIAL_NORMAL OUT_SER bank1 bsf PIE1,RCIE ;enable serial interrupt bank0 ; swapf TEMP_W,F ;Restore context swapf TEMP_STATUS,W movwf STATUS swapf TEMP_W,W ; return ;==================================== (bank0 and bank1 are macros defining RP0) It seems pretty straightforward. Is there anything I've overlooked? Is there any way around? Gennady Palitsky gennadyp@mainlink.net