there's tons of different ways... CCP in capture mode is another one. The Microchip CCP Tips and Trick is a great source of 'how to'.
The main advantage of the RA.4 T0CKI is that it's simple to use, effort less and plah plah.
Clear Timer
Do your sampling time
Read Timer
That's it. Now you can do it much complex and cross connect an INT pin to detect the rising or falling edge of your signal to do it automatically for you in background. In conjunction with a TIMER interrupt... things are just perfect. Somewhere in your INT routine, you may use a NewFrequencyAvailable to be poll in the main. Uneless this flag is not clear, it will never redo the frequency count.
This allow also an interesting feature... with the cross connect pin stuff you may also measure the period of a pulse and adjust the prescaller and/or the sampling time to be sure to don't overflow the counter. I think the microchip Frequency Counter example (a while back) use something like that.
Some PIC allow another pin and a 16 Bit Timer when you need it. T1CKI is often the name used for. Playing with the sampling time will give you the accuracy you need within the range you need.
1Sec Sampling time give you an accuracy of +/- 1Hz for a max of 65.536 KHZ
100mSec :655.36 KHZ +/- 10HZ
and so on.
Now.. i'm really asking myself why i did as much explanation... bah if this could be handy for somebody...
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks