unsigned uState=0; while(1){ switch(uState){ case 0: //stuff uState=2; break; case 1: //other stuff break; case 2: //land here uState=1; break; } }