avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: Re: [avr-chat] Error in Timing.


From: Royce Pereira
Subject: Re: Fwd: Re: [avr-chat] Error in Timing.
Date: Mon, 06 Mar 2006 15:20:57 +0530
User-agent: Opera M2/9.0 (Win32)

Hi,
On Sun, 05 Mar 2006 00:52:57 +0530, Galen Seitz <address@hidden> wrote:

In fact, even with the internal RC osc, the accuracy was acceptable
for my app. (2 sec error in 20 mins). So I could do away with the
crystal(which I had added to solve this problem).

Only inconvenience now is getting divisions to get 1ms,10ms. This was
possible with the prescaler at CK/8 (4000000/8 = 500000 i.e 0.5 ms, so
getting 10ms, 20ms was easy). Now I have prescaler at CK/256 giving
15625 Hz, a non factor of 10 :(.

It really sounds like you are doing this the hard way.  Is there
something preventing you from using Timer 1 or 2.  These timers allow
you to specify the value of TOP using an output compare register(CTC
mode).  This makes it possible to get pretty much any interrupt rate.
In your case, with the output of the prescaler at 500 KHz, you could set
OCR2 to 249 and get an OCF2 interrupt every 500 us.

Well, I'm relatively new to AVR, and havnt bothered to delve into timer 1 operation (yet). 
Just wanted to get my project up & working & Timer0 was simpler to understand ;). I 
was quickly trying to port my 8051 knowledge to AVR, & Timer0 seemed similar in 
approach to Timer0 of 8051.

But of course you are right. I need to dig furthur into the data sheet !

Thanks,
--Royce.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]