Dave you're right on the money there - I'm now getting much better stability with your suggested method, here's what I'm seeing onscreen for Timer1 counts between comparator interrupts (this was for approx 100Hz)...
Timer1 Count= 5007
Timer1 Count= 5005
Timer1 Count= 5007
Timer1 Count= 5004
Timer1 Count= 5007
Timer1 Count= 5004
Timer1 Count= 5007
Timer1 Count= 5005
Timer1 Count= 5007
Timer1 Count= 5004
Timer1 Count= 5007
Timer1 Count= 5005
Timer1 Count= 5007
Timer1 Count= 5004
Timer1 Count= 5007
Timer1 Count= 5004
Timer1 Count= 5007
Timer1 Count= 5004
...so my jitter is now something like 0.001% - that couls be down to my sigen not being stable even - it has been known to drift about a bit)
I've got a bit of a mental block with the last remaining bit though (converting to frequency in hertz! - which for all I don't actually need the result in Hz - as I'll just be comparing on the timer count alone to establish whether of not the frequency is stable - it'd be a nice to have!!)
So, what I'm seeing with my timer counts...
A 'Timer1 count' of 5000 equals 100Hz
A 'Timer1 count' of 500 = 1000Hz
Therefore the timer clock cycle = 2us (0.000002s)
What formula do I use to convert my Timer1 count into Hertz? (it's the floating point aspect that messing me up - else I'd just use this simple formula....
1 / ('timer1 count' * 0.000002)
If I add to the left side of the equation (to take the right hand side out of 'decimals' territory)...it cranks up into the millions - tilt!!!!
So how should I approach this Hertz conversion?
Bookmarks