- •Features
- •Pin Configurations
- •Overview
- •Block Diagram
- •Disclaimer
- •Pin Descriptions
- •Port C (PC5..PC0)
- •PC6/RESET
- •Port D (PD7..PD0)
- •RESET
- •AVCC
- •AREF
- •AVR CPU Core
- •Introduction
- •Architectural Overview
- •Status Register
- •Stack Pointer
- •Interrupt Response Time
- •SRAM Data Memory
- •EEPROM Data Memory
- •EEPROM Read/Write Access
- •I/O Memory
- •Clock Systems and their Distribution
- •CPU Clock – clkCPU
- •I/O Clock – clkI/O
- •Flash Clock – clkFLASH
- •ADC Clock – clkADC
- •Clock Sources
- •Crystal Oscillator
- •External RC Oscillator
- •External Clock
- •Timer/Counter Oscillator
- •Idle Mode
- •Power-down Mode
- •Power-save Mode
- •Standby Mode
- •Analog Comparator
- •Brown-out Detector
- •Internal Voltage Reference
- •Watchdog Timer
- •Port Pins
- •Resetting the AVR
- •Reset Sources
- •Power-on Reset
- •External Reset
- •Brown-out Detection
- •Watchdog Reset
- •Watchdog Timer
- •Timed Sequences for Changing the Configuration of the Watchdog Timer
- •Interrupts
- •I/O Ports
- •Introduction
- •Configuring the Pin
- •Reading the Pin Value
- •Unconnected pins
- •Alternate Port Functions
- •Alternate Functions of Port B
- •Alternate Functions of Port C
- •Alternate Functions of Port D
- •Register Description for I/O Ports
- •External Interrupts
- •8-bit Timer/Counter0
- •Overview
- •Registers
- •Definitions
- •Counter Unit
- •Operation
- •Internal Clock Source
- •Prescaler Reset
- •External Clock Source
- •16-bit Timer/Counter1
- •Overview
- •Registers
- •Definitions
- •Compatibility
- •Counter Unit
- •Input Capture Unit
- •Input Capture Trigger Source
- •Noise Canceler
- •Using the Input Capture Unit
- •Output Compare Units
- •Force Output Compare
- •Modes of Operation
- •Normal Mode
- •Fast PWM Mode
- •Phase Correct PWM Mode
- •8-bit Timer/Counter2 with PWM and Asynchronous Operation
- •Overview
- •Registers
- •Definitions
- •Counter Unit
- •Output Compare Unit
- •Force Output Compare
- •Modes of Operation
- •Normal Mode
- •Fast PWM Mode
- •Phase Correct PWM Mode
- •Timer/Counter Prescaler
- •SS Pin Functionality
- •Slave Mode
- •Master Mode
- •SPI Control Register – SPCR
- •SPI Status Register – SPSR
- •SPI Data Register – SPDR
- •Data Modes
- •USART
- •Overview
- •AVR USART vs. AVR UART – Compatibility
- •Clock Generation
- •External Clock
- •Synchronous Clock Operation
- •Frame Formats
- •Parity Bit Calculation
- •USART Initialization
- •Sending Frames with 9 Data Bits
- •Parity Generator
- •Disabling the Transmitter
- •Receiver Error Flags
- •Parity Checker
- •Disabling the Receiver
- •Flushing the Receive Buffer
- •Asynchronous Data Recovery
- •Using MPCM
- •Write Access
- •Read Access
- •Two-wire Serial Interface
- •Features
- •TWI Terminology
- •Electrical Interconnection
- •Transferring Bits
- •START and STOP Conditions
- •Address Packet Format
- •Data Packet Format
- •Overview of the TWI Module
- •SCL and SDA Pins
- •Bit Rate Generator Unit
- •Bus Interface Unit
- •Address Match Unit
- •Control Unit
- •TWI Register Description
- •TWI Bit Rate Register – TWBR
- •TWI Control Register – TWCR
- •TWI Status Register – TWSR
- •TWI Data Register – TWDR
- •Using the TWI
- •Transmission Modes
- •Master Transmitter Mode
- •Master Receiver Mode
- •Slave Receiver Mode
- •Slave Transmitter Mode
- •Miscellaneous States
- •Analog Comparator
- •Analog Comparator Multiplexed Input
- •Features
- •Starting a Conversion
- •Changing Channel or Reference Selection
- •ADC Input Channels
- •ADC Voltage Reference
- •ADC Noise Canceler
- •Analog Input Circuitry
- •ADC Accuracy Definitions
- •ADC Conversion Result
- •The ADC Data Register – ADCL and ADCH
- •ADLAR = 0
- •ADLAR = 1
- •Boot Loader Features
- •Application Section
- •BLS – Boot Loader Section
- •Boot Loader Lock Bits
- •Performing a Page Write
- •Using the SPM Interrupt
- •Setting the Boot Loader Lock Bits by SPM
- •Reading the Fuse and Lock Bits from Software
- •Preventing Flash Corruption
- •Simple Assembly Code Example for a Boot Loader
- •Fuse Bits
- •Latching of Fuses
- •Signature Bytes
- •Calibration Byte
- •Signal Names
- •Parallel Programming
- •Enter Programming Mode
- •Chip Erase
- •Programming the Flash
- •Programming the EEPROM
- •Reading the Flash
- •Reading the EEPROM
- •Programming the Lock Bits
- •Reading the Signature Bytes
- •Reading the Calibration Byte
- •Serial Downloading
- •Data Polling Flash
- •Data Polling EEPROM
- •Electrical Characteristics
- •Absolute Maximum Ratings*
- •DC Characteristics
- •External Clock Drive Waveforms
- •External Clock Drive
- •Two-wire Serial Interface Characteristics
- •ADC Characteristics
- •Active Supply Current
- •Idle Supply Current
- •Power-down Supply Current
- •Power-save Supply Current
- •Standby Supply Current
- •Pin Pull-up
- •Pin Driver Strength
- •Internal Oscillator Speed
- •Ordering Information
- •Packaging Information
- •Erratas
- •Datasheet Change Log for ATmega8
- •Changes from Rev. 2486K-08/03 to Rev. 2486L-10/03
- •Changes from Rev. 2486K-08/03 to Rev. 2486L-10/03
- •Changes from Rev. 2486J-02/03 to Rev. 2486K-08/03
- •Changes from Rev. 2486I-12/02 to Rev. 2486J-02/03
- •Changes from Rev. 2486H-09/02 to Rev. 2486I-12/02
- •Changes from Rev. 2486G-09/02 to Rev. 2486H-09/02
- •Changes from Rev. 2486F-07/02 to Rev. 2486G-09/02
- •Changes from Rev. 2486E-06/02 to Rev. 2486F-07/02
- •Changes from Rev. 2486D-03/02 to Rev. 2486E-06/02
- •Changes from Rev. 2486C-03/02 to Rev. 2486D-03/02
- •Changes from Rev. 2486B-12/01 to Rev. 2486C-03/02
- •Table of Contents
|
|
|
|
|
|
ATmega8(L) |
|
|
|
|
|
|
|
|
Pin Descriptions |
|
||||
|
|
|
||||
|
|
|
||||
|
VCC |
Digital supply voltage. |
||||
|
GND |
Ground. |
||||
|
Port B (PB7..PB0) XTAL1/ |
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each |
||||
|
XTAL2/TOSC1/TOSC2 |
bit). The Port B output buffers have symmetrical drive characteristics with both high sink |
||||
|
|
|
|
|
and source capability. As inputs, Port B pins that are externally pulled low will source |
|
|
|
|
|
|
current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset |
|
|
|
|
|
|
condition becomes active, even if the clock is not running. |
|
|
|
|
|
|
Depending on the clock selection fuse settings, PB6 can be used as input to the invert- |
|
|
|
|
|
|
ing Oscillator amplifier and input to the internal clock operating circuit. |
|
|
|
|
|
|
Depending on the clock selection fuse settings, PB7 can be used as output from the |
|
|
|
|
|
|
inverting Oscillator amplifier. |
|
|
|
|
|
|
If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6 is used as |
|
|
|
|
|
|
TOSC2..1 input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set. |
|
|
|
|
|
|
The various special features of Port B are elaborated in “Alternate Functions of Port B” |
|
|
|
|
|
|
on page 56 and “System Clock and Clock Options” on page 23. |
|
|
Port C (PC5..PC0) |
Port C is an 7-bit bi-directional I/O port with internal pull-up resistors (selected for each |
||||
|
|
|
|
|
bit). The Port C output buffers have symmetrical drive characteristics with both high sink |
|
|
|
|
|
|
and source capability. As inputs, Port C pins that are externally pulled low will source |
|
|
|
|
|
|
current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset |
|
|
|
|
|
|
condition becomes active, even if the clock is not running. |
|
|
|
|
|
|
|
|
|
PC6/RESET |
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electri- |
||||
|
|
|
|
|
cal characteristics of PC6 differ from those of the other pins of Port C. |
|
|
|
|
|
|
If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on |
|
|
|
|
|
|
this pin for longer than the minimum pulse length will generate a Reset, even if the clock |
|
|
|
|
|
|
is not running. The minimum pulse length is given in Table 15 on page 36. Shorter |
|
|
|
|
|
|
pulses are not guaranteed to generate a Reset. |
|
|
|
|
|
|
The various special features of Port C are elaborated on page 59. |
|
|
Port D (PD7..PD0) |
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each |
||||
|
|
|
|
|
bit). The Port D output buffers have symmetrical drive characteristics with both high sink |
|
|
|
|
|
|
and source capability. As inputs, Port D pins that are externally pulled low will source |
|
|
|
|
|
|
current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset |
|
|
|
|
|
|
condition becomes active, even if the clock is not running. |
|
|
|
|
|
|
Port D also serves the functions of various special features of the ATmega8 as listed on |
|
|
|
|
|
|
page 61. |
|
|
|
|
|
|||
|
RESET |
Reset input. A low level on this pin for longer than the minimum pulse length will gener- |
||||
|
|
|
|
|
ate a reset, even if the clock is not running. The minimum pulse length is given in Table |
|
|
|
|
|
|
15 on page 36. Shorter pulses are not guaranteed to generate a reset. |
5
2486M–AVR–12/03
AVCC |
|
|
|
|
|
|
|
|
|
|
|
||
AVCC is the supply voltage pin for the A/D Converter, Port C (3..0), and ADC (7..6). It |
||||||
|
should be externally connected to VCC, even if the ADC is not used. If the ADC is used, |
|||||
|
it should be connected to VCC through a low-pass filter. Note that Port C (5..4) use digital |
|||||
|
supply voltage, VCC. |
|||||
AREF |
AREF is the analog reference pin for the A/D Converter. |
|||||
ADC7..6 (TQFP and MLF |
In the TQFP and MLF package, ADC7..6 serve as analog inputs to the A/D converter. |
|||||
Package Only) |
These pins are powered from the analog supply and serve as 10-bit ADC channels. |
|||||
About Code |
This datasheet contains simple code examples that briefly show how to use various |
|||||
Examples |
parts of the device. These code examples assume that the part specific header file is |
|||||
included before compilation. Be aware that not all C compiler vendors include bit defini- |
||||||
|
||||||
|
tions in the header files and interrupt handling in C is compiler dependent. Please |
|||||
|
confirm with the C compiler documentation for more details. |
6 ATmega8(L)
2486M–AVR–12/03