|
|
View previous topic :: View next topic |
Author |
Message |
TaFFeR
Joined: 21 Apr 2007 Posts: 1
|
Jump to different location after interrupt? |
Posted: Sat Apr 21, 2007 3:36 pm |
|
|
Hi,
I'm trying to implement something that'll allow me to jump to a specific location after an port b change interrupt.
I remember a post here somewhere that addressed this, but I can't seem to find it anymore. It involved POPing the stack, and PUSHing in the new address before returning from the ISR. I'm not exactly sure how to do this or how to find the address of the line I want to jump to.
Can anyone help me out?
Thanks in advance |
|
|
Ttelmah Guest
|
|
Posted: Sun Apr 22, 2007 2:31 am |
|
|
Seriously, try to do this another way.
The problem is that while the actual 'transfer' can be made to work fairly easily, it is almost certain to lead to other problems. If (for instance), the transfer occurs while the code is inside a subroutine, then the latter return from this, may well result in problems (and remember that even if you are not directly coding routines, keeping everything in 'main', the compiler itself will call routines). The 'odds' are that you will corrupt the scratch variables, and worse, the stack. When your newly called routine 'returns'. The most likely to work solution, is not to pop the return address at all, but just to push the address of your routine. Then when your new routine finishes, it will 'return' to where the interrupt event occured, and the stack should then keep in order. Effectively you then have an extended interrupt handler, which is called, with interrupts re-enabled after the normal handler.
Otherwise, if you want to do this, then I'd really say that you need to be writing a lot in assembler, and disabling interrupts around all system routines, if problems are not going to result.
You can get the subroutine address, with 'label_address'.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|