Trigger on rising edge After Trigger fires: RISE_EDGE = CCPR1H:CCPR1L; LOOP: Trigger on falling edge After Trigger fires: FALL_EDGE = CCPR1H:CCPR1L; Pulse High Width = FALL_EDGE - RISE_EDGE; Trigger on rising edge After Trigger fires: RISE_EDGE = CCPR1H:CCPR1L; Pulse Low Width = RISE_EDGE - FALL_EDGE; Goto LOOP This takes advantage of wrap around on the 16-bit arithmetic. Bob Ammerman RAm Systems ----- Original Message ----- From: "Tony Nixon" To: Sent: Monday, July 14, 2003 7:18 PM Subject: [PIC]: Capture Module > Hi all, > > Anyone care to share how they use the capture module to monitor pulse > streams. > > Can it be done?? > > I may be wrong here, but my idea of a capture module is to > > CaptureLoop: > Activate capture function > > Hardware takes over... > { > Trigger on a valid edge > = auto reset TMR1 > = interrupt if required > > Capture on next valid edge > = auto store TMR1 as result > = auto disable capture > = interrupt if required > } > > [Capture occurred] > > if TMR1 overflowed > Bad pre/post scale factor // > $FFFF > > Process data > goto CaptureLoop > > > The capture module does not appear to work this way as TMR1 is free > running. > > This would(?) give capture scenario as... > > Monitor capture flag, or interrupt > > [Capture occurred] > { > Did TMR1 overflow? > > No > Capture value = TMR1_new - TMR1_old > TMR1_old = TMR1_new > Process & continue > > Yes > Overflowed once > if TMR1_new > TMR1_old > Bad pre/post scale factor // > $FFFF > else > Capture value = $FFFF - TMR1old + TMR1new > TMR1_old = TMR1_new > Process & continue > > More than once > Bad pre/post scale factor // > $FFFF > TMR1_old = TMR1_new > Process & continue > } > > > > regards > > Tony > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body