Re: Atmega Internal clock source accuracy



On 31 Aug 2005 04:03:27 -0700, "larwe" <larwe@xxxxxxxxx> wrote:

>
>> I find that Atmega internal 1MHz RC clock source is inaccurate. It is
>> about 95% of 1MHz. I used 3V.
>
>The internal RC source varies across V and T.
>
>> I have tried to check the oscillator calibration byte by AVRStudio and
>> then load the value into OSCCAL in the beginning of the program.
>
>You don't need to do this for the 1MHz value (usually, it depends on
>the specific chip). The 1MHz cal byte is loaded automatically at
>powerup.

The problem is that you use 3V.
The nominal internal RC frequency is for 5V.

The OP didn't say what device he is using, but I looked at the ATmega8
data***, and at shows in Fig 180 that you should indeed get about
0.95MHz at 3V, 25 °C

You could use AVRStudio to calibrate, or just try loading higher
values for OSCCAL in your program.

You can expect +/- 1% accuracy, but it highly depends on the voltage
and temperature. If needed, you can adjust OSCCAL at runtime, but do
not change the frequency by more than 2% at a time.

The most recent devices, like ATtiny2313 and ATmega48/88/168 has a
clock output option, so you can measure the frequency directly.

There is also an application note,
AVR053: Calibration of the internal RC oscillator
http://atmel.com/dyn/resources/prod_documents/doc2555.pdf
and the corresponding code files
http://atmel.com/dyn/resources/prod_documents/AVR053.zip

Tom

.