This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I wants to write a code in ISR. But Large code in ISR is not preferable. So i am going to use the inline assembly function to read the address of next instruction that stores before the interrupt occur. and store this address into local variable . and replace the address of next instruction in the stack memory with my call back function where i am going to execute all required task as done in ISR before . In call back function, after the execution of all task i simply jump to the next instruction address store in local variable. In simple, after the execution of ISR the control should return back to the next instruction address in normal way, but in my case i redirect the flow control from ISR to my call back function and from call back function return to the next instruction address.
So Question is this way of programming is preferable or not?
You forgot to save the values in all CPU registers.
If you do save the registers (and switch the stack while you're at it), you essentially have task switching. It might be a better idea to use an RTOS to begin with.
Anyway, the reason for avoiding too much code in an ISR is to prevent the main code from being interrupted for too long. Your callback function mechanism does not change that.
**Attention** This is a public forum