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

Returning from interrupt to a specified address in main

I'm quite new to context switch and embedded software development. I'm developing a standalone application (no OS) with aduc7026 and keil uVision3. My problem is that at the end of an uart messagge, which I must receive by interrupt, depending on the content of the messagge I've to return return in main in the state saved before entering in the ISR or I've have to return in a specified point where a funcion call is executed.

Hoping that I've been clear. Does anyone have suggestions?

Thank ìs in advance,

Matteo

Parents
  • depending on the content of the messagge I've to return return in main in the state saved before entering in the ISR or I've have to return in a specified point where a funcion call is executed.

    Let begin with the first part: this can be solved by maintaining the status of the main loop in a variable and s state machine - no sweat.
    Why must you return _exactly_ to a specific call? Why not then call the function in question from within the ISR itself (taking care not allowing its execution to take too long)? Remember that interrupts are by definition asynchronous and can occur while any instruction is being executed.
    If you really want to return exactly to where ypu left of, you probably want to use something like a "co-routine", based on "duff's device". But that if _not_ a standard programming technique and it comes with a price tag, but this cannot be integrated with interrupt handling in the way you want to.
    Also consider not using interrupt based reception - that way, you poll the data source, implicitly returning to where you left off before polling!

Reply
  • depending on the content of the messagge I've to return return in main in the state saved before entering in the ISR or I've have to return in a specified point where a funcion call is executed.

    Let begin with the first part: this can be solved by maintaining the status of the main loop in a variable and s state machine - no sweat.
    Why must you return _exactly_ to a specific call? Why not then call the function in question from within the ISR itself (taking care not allowing its execution to take too long)? Remember that interrupts are by definition asynchronous and can occur while any instruction is being executed.
    If you really want to return exactly to where ypu left of, you probably want to use something like a "co-routine", based on "duff's device". But that if _not_ a standard programming technique and it comes with a price tag, but this cannot be integrated with interrupt handling in the way you want to.
    Also consider not using interrupt based reception - that way, you poll the data source, implicitly returning to where you left off before polling!

Children