Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Counter/Timer Question

2005-06-20 by Ralph Hilton

On Mon, 20 Jun 2005 16:38:09 -0000 you wrote:

>
>When I use the AVR's internal oscillator or an external crystal
>oscillator, like 1.0 MHz, is the frequency 1,000,000 Hz (give or take
>a few Hz for accuracy, temp, etc)?  And not a power of 2, like 2 to
>the 20th = 1,048,576?
>
>The reason I'm asking, is because the prescaler divisors are all
>powers of 2 (i.e., 2, 4, 8, 16, 32, etc), and this makes it difficult
>to use the prescaler to get whole number frequencies.  For instance,
>if I use a 1 MHz clock and the 1024 prescaler, it gives an interval of
>0.001024 seconds instead of a nice, even number like 0.001 seconds.
>
>I guess my real question is, "Given a particular input clock, how can
>I make a timer that counts in, say, one millisecond intervals"?  And
>how can I keep it as accurate as possible over a long period of time?

For accuracy the internal RC oscillator is useless.

Xtals are available with frequencies that are a power of 2 e.g. 2097152 and
4194304 are available from my local supplier.

For long time better accuracy a TCXO can be used such as the 32768 DS32KHZ from
Maxim.


--
Ralph Hilton
http://www.ralphhilton.org
C-Meter: http://www.cmeter.org
FZAOINT http://www.fzaoint.net

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.