add the following... inside while loop

 PEOUT=count;
     count++;
     for(delay=0xffff;delay>0;delay--);//do nothing if the condition is true