Yahoo Groups archive

AVR-Chat

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

Message

Re: Mega162 RC oscillator way off calibration

2006-07-04 by kernels_nz

Hi Tim,

As I understand it, the chip only loads the osccal value for it's
lowest internal oscillator speed (1MHz usually). You have to write a
different value to the OSCCAL register for running at faster
oscillator speeds.

Also remember that the oscillator cal byte will be wrong if your not
using the supply voltage your meant to use. (Usually 5V)

The way ive done this in the past when not using the correct voltage
is I go into a loop that outputs the osccal value to the serial port,
I then incriment the osccal value and keep outputting it until I can
read the value in my terminal program. When you can read the values,
pick one in the middle of the bunch and it will be accurate enough.

Hope that helps.

Cheers
Hein B
Auckland, New Zealand

--- In AVR-Chat@yahoogroups.com, "Tim Mitchell" <tim@...> wrote:
>
> I'm using a Mega162 for the first time... It should have an 8MHz
> calibrated RC oscillator, but actually it's running at 8.45MHz which is
> making the UART communications fail. 
> 
> I've used Tinys before where you have to write your own calibration
> byte, but the data sheet seems to suggest that Atmel write the
> calibration value for you in the Megas - and the chip loads the OSCCAL
> itself on boot up. Is this correct? The data sheet is not clear on
> whether the calibration value is preloaded into the flash at the
> factory.
> 
> I can calibrate it to 8MHz myself by writing a different value to
> OSCCAL. I've used Mega8's and Mega16's lots before and the RC oscillator
> has always been spot on, or near enough to not matter.
> Any suggestions why the freq is so way off?
> 
> 
> -- 
> Tim Mitchell
> tim@...
> http://www.sabretechnology.co.uk
>

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.