On 30-Jan-02 James Fitzsimons wrote: > Hi all, > > I am trying to put togeather some code I have written and tested as seperate > programs. The problem is that each program already contains it's own > Interrupt Service Routine. > > Is it ok to call other functions from the isr? e.g. Hi James, I've no experience of using C with PICs, but there is nothing in the PIC itself to stop you calling subroutines from within the ISR and I've done it many times when writting in assembler. Two things come to mind... 1) Remember you are already one level down the stack from the interrrupt call. This will only be a probelm if you have heavily nested function calls in either the main program or the ISR. The PIC statck in only 8 deep don't forget. 2) Double check your subroutines arn't using any register files that the main program uses. > > interrupt void isr (void) > { > // check to see if interrupt on change flag set > if ( RBIE && RBIF ) > { > check_encoder(); > } > else > ..... > } > > If this is not ok how do I deal with variables declared in different files > than the file containing the isr? For example I have a variable called temp > in encoder.c , but it needs modifying in the isr, however the isr is in > iserial.c In normal C (i.e. gcc/vc++ etc) you use the "extern" keyword to tell the compiler that the variable is declared in another file and the linker puts it all together in the final linking, but please remember I said I know noting about C on PICs! Peter. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body