On Wed, 17 Apr 2002, Gordon Varney wrote: > I am using CCS, I need to enter a loop, do the loop until the > interrupt. Exit the loop, do whatever, then restart the loop. What is > the best way to exit the loop in the middle of the loop, regardless of > the status of that loop? I'd set a global variable flag in the interrupt service routine and check it in the loop, then use break if the flag is set. I assume you'll be using something other than goto for your loops... while (1) { while (1) { if (FLAG) break; } } If you can wait to exit the loop at the end of the current iteration, you could use 'while (!flag) {...}' and clear the flag in the interrupt routine. while (1) { while (!flag) { loop1... loop2... } } Dale -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads