Hi there I was playing around with some long delays and decided to get a formula for working out some of the delays, instead of just trying random values to get the desired delay. The following code contains three loops with different values. The code is called with the value for DEL1 in w. This code includes the call and return clock cycles in the formula. Note that when F8 (step through) is used the stopwatch shows an extra clock cycle, that should not be there. If you step through the delay you get the correct number of steps. e.g.. SOME INSTRUCTION MOVLW ??H <- use your DEL1 value CALL DELAY1 NEXT INSTRUCTION AFTER DELAY DELAY1 MOVWF DEL1 LOOP1 MOVLW ??H <- use your DEL2 value MOVWF DEL2 LOOP2 MOVLW ??H <- use your DEL3 value MOVWF DEL3 DECFSZ DEL3,F GOTO $-1 DECFSZ DEL2,F GOTO LOOP2 DECFSZ DEL1,F GOTO LOOP1 RETURN The delay in clock cycles is: 4*(1 + DEL1 + DEL1*DEL2) + 3*DEL1*DEL2*DEL3 Regards Gavin -------------------------- vulcan@ihug.co.nz http://www.geocities.com/TheTropics/Cabana/2625 --------------------------