Quote Originally Posted by Jerson View Post
I haven't checked your code, but, from the description, I think you need to look at it differently to get the correct results. Try it this way.

enable comparator1 and 2 interrupts

when comparator1 interrupts,
clear timer1
clear timer2
start timer1 and timer 2 running

when comparator1 interrupts again, do the following....

stop timer1 running & store the 'count' (this gives a clock pulse 'count' for the arriving frequency, but since I'm only after phase shift...which is a time based measurement, I don't calculate the frequency)

when comparator2 interrupts, stop timer2 & store the count
Actually, just re-reading your sequence - that sequence will give me the lag time direct (eg wrt a small phase lag, then comp2 will interrupt shortly after comp1)

the upper frequency that I'm hoping to measure phase shift is about 1.4Kz - a 1 deg phase shift in time for 1.4Khz is just 2us (ie 1/1440 divided by 360). At 8Mhz Osc, I'm not sure there'll be sufficient time to do much at all before the Comp2 interrupt arrives!