This is a snippet of code out of an ISR which handles pulse-width and frame-time measurements. It was written in HiTech C, but was originally in assembly (yes, I'm converting library routines). Please note that this permits startup-jitters, but the application does not care, so I got away with a little cheating. It is possible with this code to miss the first pulse on either channel. After that, it runs fine. Ignore the excess code fragments - I didn't feel like editing it. static void interrupt isr (void) { char c; UINT ThisEdge, // Time of curre nt edge being processed C1Frame, // Frame width c hannel 1 C1LastRise, // Time of last rising edge on channel 1 C1Duty, // Channel 1 dut y period C2Frame, // same for chan nel 2 C2LastRise, C2Duty; if (CCP1IF) { ThisEdge = CCPR1; CCP1IF = 0; if (C1CaptureRising) { C1CaptureRising = FALSE; C1Frame = ThisEdge - C1LastRise; C1LastRise = ThisEdge; } else { C1CaptureRising = TRUE; C1Duty = ThisEdge - C1LastRise; if ((CaptureData) && (!(FrameReady)) && (MasterCaptureData)) // Can we save t his data? eebuf.snap.Tach = C1Duty; // Yes, do it, else drop on floor } } if (CCP2IF) { ThisEdge = CCPR2; CCP2IF = 0; if (C2CaptureRising) { C2CaptureRising = FALSE; C2Frame = ThisEdge - C2LastRise; C2LastRise = ThisEdge; } else { C2CaptureRising = TRUE; C2Duty = ThisEdge - C2LastRise; if ((CaptureData) && (!(FrameReady)) && (MasterCaptureData)) // Can we save t his data? eebuf.snap.CCP2 = C2Duty; // Yes, do it, else drop on floor } } ================================================================== Andy Kunz - Statistical Research, Inc. - Westfield, New Jersey USA ==================================================================