Exact match. Not showing close matches.
'[PIC] weird issue with counting pulses using T1CLK'
I am driving into the T1CLKI pin from a function generator, say with a 100Hz square wave. The ISR is setup to use TMR0 and prescaler of 64 along with another counter to allow a 1 second timebase for timers, etc. To read the frequency is easy then, just count the number of edges that occured in the 1 second. And that works just fine, I sweep from low to high (0-255) and the frequency value in the register is whats expected. It validates that the timebase is correct as well as the frequency read is correct, and in all honesty doesn't have to be 100% exact it could be off a hz and nobody cares.
Now, they want a faster response to the change in frequency. Well since the T1 counter is running async to the system clock, its just counting transistions. I set up the ISR such that it now counts in groups of 4...meaning that I have two counters instead of one to get the 1 second timebase. Again, the count value in the frequency register matches the generator so nothing broke when I did that.
So, instead of pushing the TMR1L value to the frequency register after 1 sec transpired, I put it up where I did 1/4 of the timebase, but then the reading isn't 1/4 of the expected value..its higher. Now I can modify the 1/4 count value and get an accurate reading...moving from 25 to 19 does that (in the 1/4 count register) but now that throws off the 1 second timebase (4*1/4 second interupt). The clock is 4.1952MHz, with a TMR0 prescaler of 64. There are no other interupts happening, the only way into the ISR is when TMR0 rolls over. I'm just trying to find an explanation so I can do a correct fix rather than a band-aid.
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
More... (looser matching)
- Last day of these posts
- In 2007
, 2008 only
- New search...