At 09:37 AM 9/10/97 +0100, you wrote: >I'd like to use one of the CCP modules on the 16C74A to decode a frame >of pwm data (not unlike R/C equipment, but with 16 pwm pulses in the >frame) > >To capture the mark/space ratio, I need to capture on the leading and >the trailing edge of each pulse. > >I thought of changing the CCPCON register as soon as the first positive >edge had caused an interrupt, so that it'd capture again on the trailing >edge. > >The data book says that doing this can cause an unwanted interrupt - is >it enough to clear out the CCP1IF bit again before returning from the >first interrupt? Andy Warren's "yes" is correct. I do it this way myself in my robotic controller (which, btw, does 16 channels in/out too, at 1uS resolution on 4 MHz). Basic flow: in the ISR: if CCP1IF record captured width set CCP1 to other edge CCP1IF = 0 To save time later, I test to see if the measured edge was the rising or falling edge. If rising edge, I clear TMR1 before continuing so that I end up with a 0~2500uS value in my array of widths, and on falling edges just make sure the high period was valid. I process (validate, modify, etc) the array of widths in the foreground. Andy ================================================================== Andy Kunz - Montana Design - 409 S 6th St - Phillipsburg, NJ 08865 Hardware & Software for Industry & R/C Hobbies "Go fast, turn right, and keep the wet side down!" ==================================================================