> (from Larry, with no subject): Duh. > I have a program that is sampling an input port in a tight loop. I > want that loop to have as few instructions as possible. > > I detect a switch press by using port change interrupt. I want the > switch press to get me out of the loop and go "elsewhere" Why does it need to be so tight for detecting a mechanical switch? If the switch is pressed by a human, then you've got 10s of mS slop before anyone can notice the difference. Even if not, mechanical switches will have a few 100 uS uncertainty at least. What's the rush? Then there is bouncing. Are you really only looking at the leading edge of the switch press, or will it mess things up if the switch appears to be released and pressed again 10s of times in the first few mS? If the latter, you need to put some debouncing logic in there anyway. > I have made it work by setting a bit in the ISR, and having code in > the loop to test this bit and then exit the loop. This works just > fine, except that it adds code (and thus time) to the loop. So? How much time? Why is that a problem? How much lag can you tolerate from first switch press to PIC responding? And no, don't tell me "as fast as possible". > I'd like to have the ISR return to "elsewhere". That is likely a bad approach. Spec the problem better and step back two levels and explain the higher level problem you are trying to solve. You're not ready yet for implementation details, especially something like making the interrupt routine not return normally. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist