piclist 2001\02\23\155448a >
Thread: Frequency counting
face BY : Dan Michaels email (remove spam text)

Robert Rolf wrote:
>Drew Vassallo wrote:
>> my timer/counter routines, I always use assembler, because
>> >then I know exactly how many clock cycles everything takes,
>> >and still the overhead is sometimes a problem - but then my routines
>> >use timer1 to measure up to 60 Mhz.
>> How do you measure 60MHz with a PIC?
>Very very quickly.
>More likely, with an external prescaler.

Actually, I use the "internal" prescaler. With an external prescaler,
ie 74AC74 it can do >150 Mhz [maybe faster, but I don't have anything
goes any faster to feed in].

Basically, 16-bit Timer1 fed by the internal prescaler on pin RC0
responds successfully to signals up to 50-60 Mhz [but not to 80 or 100].
Use Timer0 to count seconds, or fractions thereof, and another counter
in RAM to keep track of TMR1IF overflows. Note - this does not require
using interrupts, just polling the flag.

The errors come in, for very fast input frequencies, in terms of the
#times the input changes as related to the overhead of monitoring the
timer flags. In other words, if it takes 2 usec to execute the loop,
during which the input changes 100 times, there is your error.

Also note --> if you look at the Mchp datasheets regarding risetimes/etc
for Timer1, you will become very confused. Mchp has revised the table
several times since the 1995 databook - so apparently they are not too
sure themselves. When feeding in 60 mhz to RC0-->prescaler-->Timer1,
you are "apparently" violating what the datasheet says, but it sure
works fine.

- dan michaels

http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


See also: www.piclist.com/techref/microchip/time.htm?key=count
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Frequency counting

month overview.

new search...