>> Temp var TMR1H
possibly part of the problem ... this gets redeclared each time through the "loop". You might want to move it up above where your other declaration resides.
>> Temp var TMR1H
possibly part of the problem ... this gets redeclared each time through the "loop". You might want to move it up above where your other declaration resides.
Paul Borgmeier
Salt Lake City, UT
USA
__________________
>>My 16F689 TMR1 counter is counting too well
After sleeping on your question, it sounds like you need a hardware debounce filter, possibly like
http://www.elexp.com/t_bounc.htm
I do not know how to add one in software when using the TMR1 as a counter. You could switch to another software means of counting all together (e.g., Interrupt on change of one of the port pins, etc) where adding software debounce would be a piece of cake.
Paul Borgmeier
Salt Lake City, UT
USA
__________________
If he is counting edges for some type of signal, a series R - shunt C filter may be better than the debounce filter. Just pick the 1/RC time constant to be higher than the max frequency of the signal you are trying to count, the nyquist freq (f*2) being a good starting point.
Tim Barr
Thanks to every one for your help. Sorry for the delay in responding, our internet connection was down for 12 hours. I am trying to count the number of switch closures of a very fast reed switch. TMR1 is counting edges on T1CKI, just as it's supposed to. Ultimately,this switch will wake the program from SLEEP, and resume counting. I haven't as yet quite figured out how to use DT's Instant Interrupts to do this, but in doing so, maybe this will help with the "debounce" problem.
For now, I may use Paul's idea of just counting the pin, or try using falingtrea's RC filter.
Thanks again.
I added debouncing for a switch to >> timer input of a F876 back in the day.
I tried using a simple R/C network but found that the slow rise time of the signal as it was charging the capacitor back up violated the maximum rise time for the pic I/O.
I ended up using the R/C filter but fed it into a schmidtt trigger prior to sending it to the timer I/O.
This took care of things, I routinely test my devices by having another pic activate a relay thousands of times and test to see that the receiving pic counted correctly.
fwiw
Bookmarks