On Tue, 28 Apr 1998, Dwayne Reid wrote: > I have 2 observations: I don't see any way for the routine to time out. It > looks as if I can either look after the watchdog or have timeout capability > but not both. I'll keep looking, tho. I think you can extend the concept to 16 samples (or whatever) per loop instead of 8 and do something like this BTFSC IOPORT,IOBIT goto went_high_x BTFSS count_high,7 ;Overflow bit BTFSC IOPORT,IOBIT goto went_high_y .... BTFSS IOPORT,IOBIT goto loop went_high_z: ..... went_high_y: BTFSC count_high,7 goto over_flowed ... > > The other observation is slightly more serious, I think. If the routine > exits without incrementing any counters, (enters the routine but the pin > went or was non-active - zero time) an erroneous result will occur. I think > the solution is simple: relpace the 'SKPZ' below with 'SKPC'. Of course - I > might be out to lunch . . . I thought about that too. The skpc to skpz change won't fix it though. It may be easier to add a flag that's initialized before the sampling begins, and is cleared in the loop. Then during the normalization you can check the flag and process the counters accordingly. It might also be necessary to sample the IOPORT once before the loop begins and abort if it's already high. Tell us how you decide to solve it :). Scott