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

Goto

Hi

Can I use GOTO statement in interrupt routine?

Example code is:

#include <REG51.H>

void ex0_isr (void) interrupt 0 /*external interrupt routine*/
{

goto NEXT;

}

void main(void) /* main program*/

{

IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2)
EX0 = 1; // Enable EX0 Interrupt
EA = 1; // Enable Global Interrupt Flag state

While(1) /* loop1*/
{
; ; /* interrupt well occur in this loop */

}


NEXT: while(1) /* loop2 */

{

; ;

}

}




Normally interrupt well occur in one loop after exciting the interrupt service routine

Again it well come to same loop. But my use is interrupt should come in one loop after that it should goto to next loop that's why here iam using GOTO state ment.


Can you give one example?

How to generate a interrupt in one loop and send into other loop.

Thanks

Regards

Nattu

Parents
  • Thanks for the reply

    If you don't mind can you give one small example program?

    Because iam new to interrupt concept.

    In my application iam using external interrupt as a switch. Normally program is in loop1(Infinite loop), when I pressed switch, control should go to loop2.

    Thanks

    Regards

    Nattu

Reply
  • Thanks for the reply

    If you don't mind can you give one small example program?

    Because iam new to interrupt concept.

    In my application iam using external interrupt as a switch. Normally program is in loop1(Infinite loop), when I pressed switch, control should go to loop2.

    Thanks

    Regards

    Nattu

Children