Hi all; I am using AT89S8252 device and Keil's C-language compiler. I have a 5.7 kb long program. Whenever user presses a button connected to External int 0, the control passes to INT_0_ISR I want to allways return back from ISR to a label 'option'. While the ISR normally will return to where it was interrupted. How can I achieve this please? - arun
"the ISR normally will return to where it was interrupted." That is the whole point of interrupts!! If that's not what you want, then don't use an interrupt! Normally, one would get the ISR to set a flag; the main code would examine this flag at appropriate points, and act accordingly.
If that's not what you want, then don't use an interrupt! I would guess that what he wants to do is 1. Run some quick high-priority stuff in the ISR. 2. Run some lower-priority stuff after the ISR but allow new/different interrupts to occur. 3. Return to normal program flow. If this is the case, either setting a flag and polling it, or putting the lower-priority stuff in a low priority ISR and set the appropriate interrupt before returning from the high priority ISR would be options.
this uttely stupid request comes up again and again and always it turns out to be some novice that try to go beyond his/her capabilities by 'inventing' an unsafe means of doing something that is emminently possible using safe proven means.. so the question to the OP will be have you made 'blinky' work? Erik
Something like:
typedef enum { Idle, Button0 } Action; Action userChoice; void isr (void) interrupt KeyboardInt { // examine the input hardware // to decide what button was hit userChoice = Button0; } void ActButton0 (void) { // things that should happen when // button 0 gets pressed } void main (void) { userChoice = Idle; // initialize kb hardware and interrupt EA = 1; for (;;) { switch (userChoice) { Button0: ActButton0(); break; Idle: // do nothing default: break; } userChoice = Idle; } }
It's possible, but not worth the effort, to try and alter the stack to return to a different point in the code. It's possible, but not worth the risk, to try and alter the stack to return to a different point in the code since this, invariably, end up as a maintainance nightmare. Of course, if you like nightmares, go ahead. Sweet dreams, Erik
Either do all the work in the interrupt handler, or just note the event and sufficient information for some later processing outside of the interrupt. Third option - put the processing in a low-priority ISR and set the appropriate interrupt before leaving the first ISR.
Hi Neil, Thank u for the reply-arun
Hi eric, Thank u for the reply-arun
Hi Drew, Thank u for the reply-arun
now 3 times you have thanked micro and he did not even post. Erik