> > You need to save everything you use which the main program might use. > > So if you use PCLATH then yes you must save it and restore it. > > thanks, it's a good answer... :) > > I've made some experiments and after some thought I'm now using (you > will find it very similar to the Microchip code on the PICs datasheets): > > #INT_GLOBAL > void interrupt(void) > { > static byte s1_save; > static byte s2_save; > static byte s3_save; > > #asm > // save registers > MOVWF s1_save > SWAPF STATUS,W > BCF STATUS,RP0 > BCF STATUS,RP1 > MOVWF s2_save > MOVF PCLATH,W > MOVWF s3_save > CLRF PCLATH > #endasm > > if (INTCON.RTCC) { > INTCON.RTCC = 0; > // do that thing you do... > } > > #asm > // restore registers > BCF STATUS,RP0 > BCF STATUS,RP1 > MOVF s3_save,W > MOVWF PCLATH > SWAPF s2_save,W > MOVWF STATUS > SWAPF s1_save,F > SWAPF s1_save,W > #endasm > } > > Best regards, > > Brusque That's okay as long as you check the code produced for the C part of your routine carefully to make sure it isn't using any other registers. I would try and do the whole routine in assembler myself so I would know for sure what registers it used. Brian Gregory. briang@cix.compulink.co.uk -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body