Do it like this: void main(void) { CMCON=7; // I am assuming this is correct, did not verify TRISA=0; // set port A, bit 0 to output TRISB=255; // set all port B to input a=150; // initialize delay time PORTA=0; // turn off output bit to start while(B0!=1); // this statement hangs waiting on hardware to force B0 on. while(1) // 1 will always evaluate to 1. therefore you cannot get out of this while loop with software { PORTA=1; // output a bit delay(); // wait on time PORTA=255; // output all bits in Port A if the default for PORTA is output delay(); // wait on time } // end while(1) } //end main I am assuming the // initiates a comment in your compiler. I cannot see any reason for the software to allow you out of the while(1) loop. I did not examine the rest of the code. I admit to being an extremist on comments. An uncommented line is an opportunity lost. If you are serious about the problem, take a herd look at ALL of the suggestions and the PIC Collective will eventually solve the problem. If you are a Troll, it is your move.... John Ferrell http://DixieNC.US -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist