This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

8051- Returning from an interrupt to a fixed location

Hi everyone,
Is there a way to return to a fixed location from an interrupt?

In my program I have something like this:

void main(void)
{
        ...//some instructions

        while(1)
        {
                ...//some instructions

                EX1=1;    //enable external interrupt 1
                my_function();
                EX1=0;   //disable external interrupt 1
        }

}

As you can see, an external interrupt 1 can occur somewhere in the middle of my_function (or in the middle of other functions that my_function calls).
And I want that when we go back from the external interrupt 1 subroutine, the processor will go right to the beginning of while(1) and SKIP the rest of my_function (instead of returning to where it was called from).

Is there a way to do this?
(And by the way, I don't care about all the local variables of any of the functions or the main. They are all irrelevant if EX1 occurs, so there's no need to save them before "returning" to that location).

I'd really appreciate your help!!

Parents Reply Children
  • If your external interrupt really is signaling such a major mess - maybe have it reset the processor and restart main?

    One reason for using an RTOS, is that an ISR can signal an event, and the RTOS can perform a task switch directly when the ISR ends, thereby waking a high-prio task to handle that event.

    Trying to invalidate the normal code flow by magic jumps just means that compiler warnings, manual reading and dedicated code analyzers will be totally unable to spot uninitialized variables, resource leaks etc.

    When you are getting stuck trying to do something fancy, that is normally an indication that you are trying to do something you shouldn't be doing.