Quote Originally Posted by HankMcSpank View Post
.got to do the 'kids off to bed' rigamrole first! Hey there's an idea...rather than read them Noddy goes to the Seaside, I could read them some of the ASM code put forward by Bert!! )
My wife, back when she was studying to be an EMT, would recite her "protocols" (sort of flow charts for emergency medical actions) to get my daughter to go to sleep.

Anyway, I've never used the DT interrupts. I've heard great things about them but never had cause to use them. I would do this by setting the registers for a single interrupt source, i.e. comparator 1. And I would use PBP interrupts (because I am a simple man...) at least at the offset. Once I had that working I would consider something more complicated (ASM interrupts) if the speed wasn't fast enough.

Perhaps in the spirit of keeping it simple, don't use *any* interrupt routine. In the main loop, just keep checking the the state of the Comp1 interrupt flag, something like

Code:
PIR2.5 = 0    'Clear the Comp1 interrupt flag
Main_Loop:
    WHILE PIR2.5 = 0
        GOTO Main_Loop
    WEND
        Comp1Time.Lowbyte = TMR1L  'Store away the timer1 count - this  will be the non lagged signal 'period' count.
        Comp1Time.Highbyte = TMR1H    
        TMR1H = 0                     'Set timer1 value to 0
        TMR1L = 0
        PIR2.6 = 0                     'Clear the Comparator C2 Interrupt Flag bit
Keep_Waiting:
        WHILE  PIR2.6 = 0         'Check to see if the Comparator 2 interrupt flag has flipped
            goto Keep_Wating
        WEND
        Comp2Time.Lowbyte = TMR1L    'Store away the timer1 count again (ie once the lagged signal leading edge arrives - this is the lag count)
        Comp2Time.Highbyte = TMR1H    
        HSEROUT ["comp1=",dec Comp1Time,9,"comp2Time=", dec comp2time, 13, 10]
        PIR2.5 = 0    'Clear the Comp1 interrupt flag
        goto Main_Loop
END
Best Regards,
Paul