Jump to content


jump to main() inside ISR

  • Please log in to reply
1 reply to this topic

#1 xolang1


    Junior Member

  • Members
  • PipPip
  • 9 posts
  • Location:Baguio City

Posted 28 April 2005 - 04:57 AM

In codevision 1.23, how does one jump from the interrupt subroutine to main()? I'd like to a code that will uses a timer to time 2 seconds after a certain event in main() occurs. when s secs is seen in the interrupt subroutine, it executes some code lines then if should go back to a certain line in the main code other than the point where the interrupt routine goes...

I was thinking of a forced jump instruction... any ideas?

#2 marke


    Posting Freak

  • Moderator
  • PipPipPipPipPipPip
  • 2,642 posts
  • Gender:Male
  • Location:Christchurch, New Zealand

Posted 28 April 2005 - 09:00 AM

Hello xolang1

I do not know why you would want to jump to main inside an interrupt routine. If you try, you will still be in the interrupt routine until you get to the exit code. You could create all sorts of problems if you were abloe to stack up interrupts.
If you wish to force the exit from interrupt to go to a particular address rather than returning to where the interrupt was called from, you can push the new return address onto the stack before the RETI. You should becareful not to push more than you pop, otherwise you will get a stack overflow.
I use this technique if I want to do a warm boot on an error such as a timeout error.
If you want to let the interrupt routine determine a main line function, you can set up a series of semaphores. In operation, the mainline code continually tests the semaphores, and the interrupt routines set the semaphores.

Perhaps you could give more detail of your requirements and someone may be able to be more specific in the reply.

Best regards,

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users