We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have a general question regarding handling ISRs which stems from my inexperience. My understanding of ISR is that the execution branches, from the main code, to the ISR upon a condition being satisfied. After executing the ISR code it goes back to the main code, essentially back to the point where it paused to go to the ISR. My question is can I call another function within the ISR instead of having the execution go back to where it had left off? Would it cause any adverse effects? I am sure I must have confused some people by now for which i would like to apologize. Your criticisms/comments are welcome.
The definition of a "call" is that it will return.
The definition of a "jump" is that it is a one-way change of execution point.
Yes, your ISR can call functions. When these functions ends, they will return back to the ISR. When the ISR ends, the processor will return to your main program (or if you run an RTOS, the ISR will return to any of your waiting threads - not always the same thread that was running when the ISR started).
But for best function, you should always try to keep your ISR short and fast. And that means that you should try to avoid to call functions from the ISR. Do what you need to do, and then let the ISR end.
One risk with calling functions from an ISR is that the "interrupted" code might also have been using the same function!
This, in itself, needn't be a problem - but it can cause some very "interesting" problems if you're not careful about it...!