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
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
If you don't mind can you give one small example program? I'll try.
#include <REG51.H> bit loopswitch = 0; void ex0_isr (void) interrupt 0 /*external interrupt routine*/ { (do some stuff) loopswitch = 1; } 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(!loopswitch) /* loop1*/ {} while(1) /* loop2 */ {} }
http://www.keil.com/download/list/c51.htm http://www.keil.com/books/8051books.asp http://www.8052.com/books.phtml http://www.8052.com/book
Thank you for the reply Now it is working well. Regards Nattu
Now it is working well. Good. Hopefully, you also learned from the example instead of just copying it.