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.

How jump after interrupt to another function (other then I left)?



Hello,

Im working with f28335 without BIOS.
and writing in C.

I'm intend to use with Timer_1 as interrupt.
the idea is that in case interrupt
the ISR  will decide how the program will
continue after the interrupt.

just to be clear, in case that the code
running function "func_A". and now interrupt
event occur
I need to change the code flow to
function B "func_B". I'm not suppose to
return from interupt to "func_A" but to
continue directly (at the end of ISR)
to "func_B".

I read about the cpu interrupt .
and i see that when interrupt occur:
1. the pc is saved in the stack.
2. at the interrupt end (with the instruction IRET)
    the PC restore automatically from the stack.

hence, in order to jump after the interrupt to
another funcion, the ISR need to change
the PC address that store in the stack.

1. How i do it?
2. where exactly the place of the PC
   that  store in the stack?
3. where can i get asm code examples?

Thanks.
Asher.


  • Asher,

    While this is completely doable with the processor, this type of program flow is very unsafe and is not recommended for use in any application.

    Instead of doing what you've suggested, I would instead use the ISR to set some global program flow variables that effected how the non-interrupt code executed.  You should be able to accomplish something very similar to what you have suggested without modifying the stack.  Do you have a specific reason you need to start executing a different function after the ISR or was this just simply the first method you came up with to accomplish what you need in your application?  I strongly recommend you reconsider the architecture of your application.

    Regards,

    Trey

  • Trey German said:
    I strongly recommend you reconsider the architecture of your application

    Absolutely!

    This is a very common novice question which turns up again & again with monotonous regularity!

    If you really can't do as Trey suggests - which is the normal approach to non-RTOS embedded programming - then you should be looking at one of the many readily-available RTOS offerings.