Dave and Sandy Thomas wrote: > ; delay 1 millimeter = 6 microseconds = 12 cycles at 8.0 MHz > rdloop: > incf range,1 ; 0 increment range > btfsc status,zf ; 1 > incf range+1,1 ; 2 > movf range+1,w ; 3 test for timeout - 10752 mm > xorlw (maxrange/256)+1 ; 4 > btfsc status,zf ; 5 > goto rddone ; 6 > btfss portb,echo ; 7 test for echo > goto rdloop ; 8 > rddone: > > My calculations agree that echo transit time is approximately > 6 microseconds per millimeter (3 microseconds one way). But > I count only 10 cycles per loop--so does MPSIM (under MPLAB). Dave: You and MPSIM are correct; the loop takes 10 cycles per iteration (except for the last time through, of course, when it takes either 8 or 9). -Andy Andrew Warren - fastfwd@ix.netcom.com Fast Forward Engineering, Vista, California http://www.geocities.com/SiliconValley/2499