Possibly in MPASM format... main btfsc PORTB,inbit goto main do1 bsf maskB,0 bsf maskB,4 wait1a movf maskB,W movwf PORTB btfss PORTB,inbit goto wait1a ;end of phase 1 clrf maskB low movf maskB,W movwf PORTB call ResetTimeout wait1b btfss PORTB,inbit goto wait1b phase call CheckTimeout btfsc STATUS,Z goto wait1b goto main This seems ok depending on ResetTimeout and CheckTimeout. Appologies before for the consecutive BSF instructions, I thought they were referring to a PORT, not a RAM register. regards Tony -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu