Bob Blick wrote: > I'm using a 16F88 to measure and accumulate quite variable length > positive pulses with high precision. > > This means I need more than the standard 16 bit resolution of the CCP1 > peripheral, so I am trying to extend it by counting Timer 1 overflows > by monitoring TMR1IF while making sure I only count the ones that > happen during the positive pulse. The race conditions get very tricky with this method. Think very carefully what happens when timer 1 overflows right before or after the capture interrupt. I've had to do this a few times, usually for frequency measurement applications where there was a large dynamic range. I use a foreground routine that looks at the high byte of timer 1 only. It keeps a copy of the previous snapshot, takes the difference, and add that to a software accumulator that can be as wide as you want. In the capture interrupt, you do the normal subtract from the starting value but then also add in whatever is in the wide software accumulator. The foreground routine only needs to be run a little more often than the timer 1 wrap period. In practise I usually try to run it at twice that rate so that there is plenty of slop. This routine will disable the capture interrupt for a few cycles so the update of the software accumulator will be atomic. However, that only delays the interrupt itself a little bit. The correct capture value is still saved in the CCP module. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist