Hi,I posted this in wrong section,sorry. Using timer1 and displaying time between pin high and low the pin fed from signal gen 1 to 100 hz and changing clock and prescaler the display values vary a lot from 4 to 5 digits.Any idea why. The signal gen seems ok on scope. The line #define I2C_DISABLE_INTERRUPTS ON shouldn't affect timer1? Would it affect an interrupt on timer1 overflow?
converted from timer1 microchip example in timer help. Cheers
Of course! 5v is not just on and 0v is not just off. Doh.
Hmm thinking again
~~~
ClearTimer 1
Do until Switch = 0:Loop
Do until Switch = 1:Loop
~~~
It's still not defined logic level. What's the difference?
Playing with idea is interesting seeing repeated samples on lcd.
Last edit: stan cartwright 2017-06-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,I posted this in wrong section,sorry. Using timer1 and displaying time between pin high and low the pin fed from signal gen 1 to 100 hz and changing clock and prescaler the display values vary a lot from 4 to 5 digits.Any idea why. The signal gen seems ok on scope. The line #define I2C_DISABLE_INTERRUPTS ON shouldn't affect timer1? Would it affect an interrupt on timer1 overflow?
converted from timer1 microchip example in timer help. Cheers
Last edit: stan cartwright 2017-06-10
The code is measuring partial pulses because it starts measuring abritrarily upon any high level, even if it half way through a pulse.
Add a test at the beginning of the loop so that if the pulse is already high, wait for it to go low. Then start measuring on the next positive edge.
So add this right after "cleartimer"
.
~~~~
Do until Switch = 0
Loop
~~~~
Of course! 5v is not just on and 0v is not just off. Doh.
Hmm thinking again
~~~
ClearTimer 1
Do until Switch = 0:Loop
Do until Switch = 1:Loop
~~~
It's still not defined logic level. What's the difference?
Playing with idea is interesting seeing repeated samples on lcd.
Last edit: stan cartwright 2017-06-11
By changing the input level I can see the trigger (schmit?) point. I'll be aware of that in future if it causes me probs. Ta for reply.