Bob Ammerman wrote: > Of course this doesn't support re-entrancy or recursion, and can get messy > if the same function is called from an interrupt and mainline code. In the case of the Hi-Tech PICC/PICC-18, calling functions from an ISR and from main code can get messy, but doesn't have to. By default it is not allowed; the compiler creates a call tree for main and one for each interrupt vector, and there are no common functions allowed in different call trees. One can mark a function to be allowed to be called by two or more call trees (with "#pragma interrupt_level"). In this case it is the program's responsibility to make sure that this function never gets called from one call tree while it is already running in another; that is, the program needs to control access to it. (This is because these compilers don't support re-entrancy, as Bob said.) Commonly, the interrupt that calls it (or all interrupts) gets disabled before entering the function in the main code. If nothing speaks against it, this is a simple and clean method to use a function in more than one call tree. Gerhard -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist