Oh dear - I spoke to soon!
(5 nights & counting for this seemingly simple task! Eek!)
by & large the overall process works, however.....
If I take the phase shift control of my all pass filter circuit down to as near as damnit zero degrees phase shift (ie no lag for the second signal feeding into comparator 2), then there ought to be almost a zero count when the second comparator interrupts, alas, in actual fact there appears to be count of about 325 for comparator2 in this scenario (@1khz). If I take the tst frequency down to 100Hz, I see a comparator2 count of a whopping 3000 (albeit comparator1 reads 50,000 in this scenarion - so it's pro rata)
this means @1khz, with that error I'm getting a phase shift of about 23 degrees being erroneouly calculated - ie 5000 (1st timer count) divided by 360 (degrees) muyltiplied by 325 (second timer count) - but I know for a fact there's actually no phase shift present at all (I can see this on my scope).
Now I know I'm relatively new to all this, but I can't help feeling there something going seriously wrong 'behind the scenes' (or a config register setting?).... my reasoning is that there's virtually no code for me to screw up with here!
here's my interrupt handler...
Code:
Comp1_Int:
Comp1Time.Lowbyte = TMR1L 'Store away the timer1 count
Comp1Time.Highbyte = TMR1H 'Store away the timer1 count.
TMR1H = 0 'Set the high part of the timer value to 0
TMR1L = 0 'Set the low part of the timer value to 0
@ INT_RETURN
Comp2_Int:
Comp2Time.Lowbyte = TMR1L 'Store away the timer1 count
Comp2Time.Highbyte = TMR1H 'Store away the timer1 count
@ INT_RETURN
Anyone got any ideas?!
Bookmarks