beautypg.com

11 register description, 1 osccal - oscillator calibration value, Osccal – oscillator calibration value" on – Rainbow Electronics ATmega128RFA1 User Manual

Page 153: Atmega128rfa1

background image

153


8266A-MCU Wireless-12/09

ATmega128RFA1

possible to determine the state of the prescaler - even if it were readable. The exact
time it takes to switch from one clock division to another cannot be exactly predicted.
From the time the CLKPS values are written, it takes between t

1

+ t

2

and t

1

+ 2t

2

before

the new clock frequency is active. In this interval 2 active clock edges are produced.
Here t

1

is the previous clock period and t

2

is the clock period corresponding to the new

prescaler setting.

To avoid unintentional changes of clock frequency, a special write procedure must be
followed to change the CLKPS bits:

1. Write the Clock Prescaler Change Enable (CLKPCE) bit to one and all other bits in

CLKPR to zero.

2. Within four cycles, write the desired value to CLKPS while writing a zero to

CLKPCE.

Interrupts must be disabled when changing prescaler settings to make sure the write
procedure is not interrupted.

It is not required to change the prescaler setting of an existing software package written
for an 8MHz internal RC oscillator. The change of the prescaler (additional 1:2 divider)
is compensated by doubling the RC oscillator frequency of the ATmega128RFA1.

11.11 Register Description

11.11.1 OSCCAL – Oscillator Calibration Value

Bit

7

6

5

4

3

2

1

0

NA ($66)

CAL7

CAL6

CAL5

CAL4

CAL3

CAL2

CAL1

CAL0

OSCCAL

Read/Write

R/W

R/W

R/W

R/W

R/W

R/W

R/W

R/W

Initial Value

0

0

0

0

0

0

0

0

The Oscillator Calibration Register is used to trim the Calibrated Internal RC Oscillator
to remove process variations from the oscillator frequency. A preprogrammed
calibration value is automatically written to this register during chip reset, giving the
Factory calibrated frequency. The application software can write this register to change
the oscillator frequency. The oscillator can be calibrated to frequencies as specified in
the section "Electrical Characteristics". Calibration outside that range is not guaranteed.
Note that this oscillator is used to time EEPROM and Flash write accesses and these
write times will be affected accordingly. The calibration to very high frequencies can
cause EEPROM or Flash erase/write failures. The CAL7 bit determines the range of
operation for the oscillator. Setting this bit to 0 gives the lowest frequency range, setting
this bit to 1 gives the highest frequency range. The two frequency ranges are
overlapping, in other words a setting of OSCCAL = 0x7F gives a higher frequency than
OSCCAL = 0x80. The CAL6..0 bits are used to tune the frequency within the selected
range. A setting of 0x00 gives the lowest frequency in that range, and a setting of 0x7F
gives the highest frequency in the range.

Bit 7:0 – CAL7:0 - Oscillator Calibration Tuning Value

Table 11-11 CAL Register Bits

Register Bits

Value

Description

0x00

Calibration value for lowest oscillator
frequency

0x7f

End value of low frequency range calibration

CAL7:0

0x80

Start value of high frequency range
calibration