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

want to go to a lable

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

Parents
  • 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;
            }
        }
    

    A more elaborate scheme would post a message back to the main loop, so you could queue multiple events.

    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. It's possible, but not worth the effort, to try and alter the stack to return to a different point in the code.

Reply
  • 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;
            }
        }
    

    A more elaborate scheme would post a message back to the main loop, so you could queue multiple events.

    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. It's possible, but not worth the effort, to try and alter the stack to return to a different point in the code.

Children