ATmega8 (961730), страница 6
Текст из файла (страница 6)
This allows halting the CPU andI/O clocks in order to reduce noise generated by digital circuitry. This gives more accurate ADC conversion results.Clock SourcesThe device has the following clock source options, selectable by Flash Fuse Bits asshown below. The clock from the selected source is input to the AVR clock generator,and routed to the appropriate modules.Table 2. Device Clocking Options Select(1)Device Clocking OptionCKSEL3..0External Crystal/Ceramic Resonator1111 - 1010External Low-frequency Crystal1001External RC Oscillator1000 - 0101Calibrated Internal RC Oscillator0100 - 0001External ClockNote:00001. For all fuses “1” means unprogrammed while “0” means programmed.The various choices for each clocking option is given in the following sections. When theCPU wakes up from Power-down or Power-save, the selected clock source is used totime the start-up, ensuring stable Oscillator operation before instruction execution starts.When the CPU starts from reset, there is as an additional delay allowing the power toreach a stable level before commencing normal operation.
The Watchdog Oscillator isused for timing this real-time part of the start-up time. The number of WDT Oscillatorcycles used for each time-out is shown in Table 3. The frequency of the Watchdog Oscillator is voltage dependent as shown in “ATmega8 Typical Characteristics”. The device isshipped with CKSEL = “0001” and SUT = “10” (1 MHz Internal RC Oscillator, slowly rising power).Table 3.
Number of Watchdog Oscillator Cycles24Typical Time-out (VCC = 5.0V)Typical Time-out (VCC = 3.0V)Number of Cycles4.1 ms4.3 ms4K (4,096)65 ms69 ms64K (65,536)ATmega8(L)2486O–AVR–10/04ATmega8(L)Crystal OscillatorXTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which canbe configured for use as an On-chip Oscillator, as shown in Figure 11. Either a quartzcrystal or a ceramic resonator may be used. The CKOPT Fuse selects between two different Oscillator amplifier modes.
When CKOPT is programmed, the Oscillator outputwill oscillate a full rail-to-rail swing on the output. This mode is suitable when operatingin a very noisy environment or when the output from XTAL2 drives a second clockbuffer. This mode has a wide frequency range. When CKOPT is unprogrammed, theOscillator has a smaller output swing. This reduces power consumption considerably.This mode has a limited frequency range and it cannot be used to drive other clockbuffers.For resonators, the maximum frequency is 8 MHz with CKOPT unprogrammed and16 MHz with CKOPT programmed. C1 and C2 should always be equal for both crystalsand resonators.
The optimal value of the capacitors depends on the crystal or resonatorin use, the amount of stray capacitance, and the electromagnetic noise of the environment. Some initial guidelines for choosing capacitors for use with crystals are given inTable 4. For ceramic resonators, the capacitor values given by the manufacturer shouldbe used.Figure 11. Crystal Oscillator ConnectionsC2C1XTAL2XTAL1GNDThe Oscillator can operate in three different modes, each optimized for a specific frequency range. The operating mode is selected by the fuses CKSEL3..1 as shown inTable 4.Table 4.
Crystal Oscillator Operating ModesCKOPTCKSEL3..1FrequencyRange(MHz)Recommended Range for CapacitorsC1 and C2 for Use with Crystals (pF)1101(1)0.4 - 0.9–11100.9 - 3.012 - 2211113.0 - 8.012 - 220101, 110, 1111.0 ≤12 - 22Note:1. This option should not be used with crystals, only with ceramic resonators.The CKSEL0 Fuse together with the SUT1..0 Fuses select the start-up times as shownin Table 5.252486O–AVR–10/04Table 5. Start-up Times for the Crystal Oscillator Clock SelectionCKSEL0SUT1..0Start-up Timefrom Power-downand Power-save000258 CK(1)4.1 msCeramic resonator, fastrising power001258 CK(1)65 msCeramic resonator, slowlyrising power0101K CK(2)–Ceramic resonator, BODenabled0111K CK(2)4.1 msCeramic resonator, fastrising power1001K CK(2)65 msCeramic resonator, slowlyrising power10116K CK–Crystal Oscillator, BODenabled11016K CK4.1 msCrystal Oscillator, fastrising power11116K CK65 msCrystal Oscillator, slowlyrising powerNotes:Low-frequency CrystalOscillatorAdditional Delayfrom Reset(VCC = 5.0V)Recommended Usage1.
These options should only be used when not operating close to the maximum frequency of the device, and only if frequency stability at start-up is not important for theapplication. These options are not suitable for crystals.2. These options are intended for use with ceramic resonators and will ensure frequency stability at start-up.
They can also be used with crystals when not operatingclose to the maximum frequency of the device, and if frequency stability at start-up isnot important for the application.To use a 32.768 kHz watch crystal as the clock source for the device, the Low-frequency Crystal Oscillator must be selected by setting the CKSEL Fuses to “1001”. Thecrystal should be connected as shown in Figure 11. By programming the CKOPT Fuse,the user can enable internal capacitors on XTAL1 and XTAL2, thereby removing theneed for external capacitors. The internal capacitors have a nominal value of 36 pF.When this Oscillator is selected, start-up times are determined by the SUT Fuses asshown in Table 6.Table 6.
Start-up Times for the Low-frequency Crystal Oscillator Clock SelectionSUT1..0Start-up Time fromPower-down andPower-saveAdditional Delayfrom Reset(VCC = 5.0V)001K CK(1)4.1 msFast rising power or BOD enabled01(1)1K CK65 msSlowly rising power1032K CK65 msStable frequency at start-up11Note:26Recommended UsageReserved1. These options should only be used if frequency stability at start-up is not importantfor the application.ATmega8(L)2486O–AVR–10/04ATmega8(L)External RC OscillatorFor timing insensitive applications, the external RC configuration shown in Figure 12can be used. The frequency is roughly estimated by the equation f = 1/(3RC). C shouldbe at least 22 pF.
By programming the CKOPT Fuse, the user can enable an internal 36pF capacitor between XTAL1 and GND, thereby removing the need for an externalcapacitor.Figure 12. External RC ConfigurationVCCRNCXTAL2XTAL1CGNDThe Oscillator can operate in four different modes, each optimized for a specific frequency range. The operating mode is selected by the fuses CKSEL3..0 as shown inTable 7.Table 7. External RC Oscillator Operating ModesCKSEL3..0Frequency Range (MHz)01010.1 - 0.901100.9 - 3.001113.0 - 8.010008.0 - 12.0When this Oscillator is selected, start-up times are determined by the SUT Fuses asshown in Table 8.Table 8.
Start-up Times for the External RC Oscillator Clock SelectionSUT1..0Start-up Time fromPower-down andPower-saveAdditional Delayfrom Reset(VCC = 5.0V)0018 CK–0118 CK4.1 msFast rising power1018 CK65 msSlowly rising power11(1)4.1 msFast rising power or BOD enabledNote:6 CKRecommended UsageBOD enabled1. This option should not be used when operating close to the maximum frequency ofthe device.272486O–AVR–10/04Calibrated Internal RCOscillatorThe calibrated internal RC Oscillator provides a fixed 1.0, 2.0, 4.0, or 8.0 MHz clock.
Allfrequencies are nominal values at 5V and 25°C. This clock may be selected as the system clock by programming the CKSEL Fuses as shown in Table 9. If selected, it willoperate with no external components. The CKOPT Fuse should always be unprogrammed when using this clock option. During reset, hardware loads the 1 MHzcalibration byte into the OSCCAL Register and thereby automatically calibrates the RCOscillator.
At 5V, 25°C and 1.0 MHz Oscillator frequency selected, this calibration givesa frequency within ± 3% of the nominal frequency. Using run-time calibration methodsas described in application notes available at www.atmel.com/avr it is possible toachieve ± 1% accuracy at any given VCC and Temperature. When this Oscillator is usedas the chip clock, the Watchdog Oscillator will still be used for the Watchdog Timer andfor the Reset Time-out.
For more information on the pre-programmed calibration value,see the section “Calibration Byte” on page 222.Table 9. Internal Calibrated RC Oscillator Operating ModesNote:CKSEL3..0Nominal Frequency (MHz)0001(1)1.000102.000114.001008.01. The device is shipped with this option selected.When this Oscillator is selected, start-up times are determined by the SUT Fuses asshown in Table 10. PB6 (XTAL1/TOSC1) and PB7(XTAL2/TOSC2) can be used aseither general I/O pins or Timer Oscillator pins..Table 10. Start-up Times for the Internal Calibrated RC Oscillator Clock SelectionSUT1..0Start-up Time fromPower-down andPower-saveAdditional Delayfrom Reset(VCC = 5.0V)006 CK–016 CK4.1 msFast rising power6 CK65 msSlowly rising power(1)1011Note:28Recommended UsageBOD enabledReserved1.
The device is shipped with this option selected.ATmega8(L)2486O–AVR–10/04ATmega8(L)Oscillator Calibration Register– OSCCALBitRead/Write76543210CAL7CAL6CAL5CAL4CAL3CAL2CAL1CAL0R/WR/WR/WR/WR/WR/WR/WR/WInitial ValueOSCCALDevice Specific Calibration Value• Bits 7..0 – CAL7..0: Oscillator Calibration ValueWriting the calibration byte to this address will trim the Internal Oscillator to remove process variations from the Oscillator frequency.
During Reset, the 1 MHz calibration valuewhich is located in the signature row High byte (address 0x00) is automatically loadedinto the OSCCAL Register. If the internal RC is used at other frequencies, the calibrationvalues must be loaded manually. This can be done by first reading the signature row bya programmer, and then store the calibration values in the Flash or EEPROM. Then thevalue can be read by software and loaded into the OSCCAL Register. When OSCCAL iszero, the lowest available frequency is chosen. Writing non-zero values to this registerwill increase the frequency of the Internal Oscillator.
Writing 0xFF to the register givesthe highest available frequency. The calibrated Oscillator is used to time EEPROM andFlash access. If EEPROM or Flash is written, do not calibrate to more than 10% abovethe nominal frequency. Otherwise, the EEPROM or Flash write may fail. Note that theOscillator is intended for calibration to 1.0, 2.0, 4.0, or 8.0 MHz. Tuning to other values isnot guaranteed, as indicated in Table 11.Table 11.















