- •Features
- •Pin Configurations
- •Overview
- •Block Diagram
- •Pin Descriptions
- •Port A (PA7..PA0)
- •Port B (PB7..PB0)
- •Port C (PC7..PC0)
- •Port D (PD7..PD0)
- •Port E (PE7..PE0)
- •Port F (PF7..PF0)
- •Port G (PG4..PG0)
- •RESET
- •XTAL1
- •XTAL2
- •AVCC
- •AREF
- •AVR CPU Core
- •Introduction
- •Architectural Overview
- •Status Register
- •Stack Pointer
- •Interrupt Response Time
- •SRAM Data Memory
- •Data Memory Access Times
- •EEPROM Data Memory
- •EEPROM Read/Write Access
- •I/O Memory
- •Overview
- •ATmega103 Compatibility
- •Address Latch Requirements
- •Pull-up and Bus-keeper
- •Timing
- •XMEM Register Description
- •Using all 64KB Locations of External 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
- •Extended Standby Mode
- •Analog to Digital Converter
- •Analog Comparator
- •Brown-out Detector
- •Internal Voltage Reference
- •Watchdog Timer
- •Port Pins
- •System Control and Reset
- •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 Watch Dog Timer
- •Safety Level 0
- •Safety Level 1
- •Safety Level 2
- •Interrupts
- •I/O-Ports
- •Introduction
- •Configuring the Pin
- •Reading the Pin Value
- •Alternate Port Functions
- •Alternate Functions of Port A
- •Alternate Functions of Port B
- •Alternate Functions of Port C
- •Alternate Functions of Port D
- •Alternate Functions of Port E
- •Alternate Functions of Port F
- •Alternate Functions of Port G
- •Port A Data Register – PORTA
- •Port B Data Register – PORTB
- •Port C Data Register – PORTC
- •Port D Data Register – PORTD
- •Port E Data Register – PORTE
- •Port F Data Register – PORTF
- •Port G Data Register – PORTG
- •External Interrupts
- •8-bit Timer/Counter0 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
- •16-bit Timer/Counter (Timer/Counter1 and Timer/Counter3)
- •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
- •16-bit Timer/Counter Register Description
- •Internal Clock Source
- •Prescaler Reset
- •External Clock Source
- •8-bit Timer/Counter2 with PWM
- •Overview
- •Registers
- •Definitions
- •Counter Unit
- •Output Compare Unit
- •Force Output Compare
- •Modes of Operation
- •Normal Mode
- •Fast PWM Mode
- •Phase Correct PWM Mode
- •Overview
- •Description
- •Timing Example
- •Slave Mode
- •Master Mode
- •SPI Control Register – SPCR
- •SPI Status Register – SPSR
- •SPI Data Register – SPDR
- •Data Modes
- •USART
- •Dual 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 5 to 8 Data Bit
- •Sending Frames with 9 Data Bit
- •Parity Generator
- •Disabling the Transmitter
- •Receiving Frames with 5 to 8 Data Bits
- •Receiving Frames with 9 Data Bits
- •Receiver Error Flags
- •Parity Checker
- •Disabling the Receiver
- •Flushing the Receive Buffer
- •Asynchronous Data Recovery
- •Using MPCM
- •Two-wire Serial Interface
- •Features
- •TWI Terminology
- •Electrical Interconnection
- •Transferring Bits
- •START and STOP Conditions
- •Address Packet Format
- •Data Packet Format
- •Multi-master Bus Systems, Arbitration and Synchronization
- •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
- •Analog to Digital Converter
- •Features
- •Operation
- •Starting a Conversion
- •Differential Gain Channels
- •ADC Input Channels
- •ADC Voltage Reference
- •ADC Noise Canceler
- •Analog Input Circuitry
- •ADC Accuracy Definitions
- •ADC Conversion Result
- •ADLAR = 0:
- •ADLAR = 1:
- •Features
- •Overview
- •Test Access Port – TAP
- •TAP Controller
- •PRIVATE0; $8
- •PRIVATE1; $9
- •PRIVATE2; $A
- •PRIVATE3; $B
- •Bibliography
- •Features
- •System Overview
- •Data Registers
- •Bypass Register
- •Device Identification Register
- •Reset Register
- •Boundary-scan Chain
- •EXTEST; $0
- •IDCODE; $1
- •SAMPLE_PRELOAD; $2
- •AVR_RESET; $C
- •BYPASS; $F
- •Boundary-scan Chain
- •Scanning the Digital Port Pins
- •Scanning the RESET Pin
- •Scanning the Clock Pins
- •Scanning the ADC
- •Boot Loader Features
- •Application Section
- •Boot Loader Section – BLS
- •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
- •AVR_RESET ($C)
- •PROG_ENABLE ($4)
- •PROG_COMMANDS ($5)
- •PROG_PAGELOAD ($6)
- •PROG_PAGEREAD ($7)
- •Data Registers
- •Reset Register
- •Programming Enable Register
- •Virtual Flash Page Read Register
- •Programming Algorithm
- •Entering Programming Mode
- •Leaving Programming Mode
- •Performing Chip Erase
- •Programming the Flash
- •Reading the Flash
- •Programming the EEPROM
- •Reading the EEPROM
- •Programming the Fuses
- •Programming the Lock Bits
- •Reading the Signature Bytes
- •Reading the Calibration Byte
- •Electrical Characteristics
- •Absolute Maximum Ratings*
- •DC Characteristics
- •External Clock Drive Waveforms
- •External Clock Drive
- •2-wire Serial Interface Characteristics
- •ADC Characteristics - Preliminary Data
- •External Data Memory Timing
- •Ordering Information
- •Packaging Information
|
|
|
|
|
|
|
|
ATmega128(L) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The ATmega128 is 100% pin compatible with ATmega103, and can replace the |
|||||
|
|
|
||||||
|
|
|
ATmega103 on current Printed Circuit Boards. The application note “Replacing |
|||||
|
|
|
ATmega103 by ATmega128” describes what the user should be aware of replacing the |
|||||
|
|
|
ATmega103 by an ATmega128. |
|||||
|
ATmega103 Compatibility |
By programming the M103C fuse, the ATmega128 will be compatible with the |
||||||
|
Mode |
ATmega103 regards to RAM, I/O pins and interrupt vectors as described above. How- |
||||||
|
|
|
ever, some new features in ATmega128 are not available in this compatibility mode, |
|||||
|
|
|
these features are listed below: |
|||||
|
|
|
• One USART instead of two, asynchronous mode only. Only the 8 least significant |
|||||
|
|
|
bits of the Baud Rate Register is available. |
|||||
|
|
|
• One 16 bits Timer/Counter with 2 compare registers instead of two 16-bit |
|||||
|
|
|
Timer/Counters with 3 compare registers. |
|||||
|
|
|
• 2-wire serial interface is not supported. |
|||||
|
|
|
• Port G serves alternate functions only (not a general I/O port). |
|||||
|
|
|
• Port F serves as digital input only in addition to analog input to the ADC. |
|||||
|
|
|
• Boot Loader capabilities is not supported. |
|||||
|
|
|
• It is not possible to adjust the frequency of the internal calibrated RC oscillator. |
|||||
|
|
|
• The External Memory Interface can not release any Address pins for general I/O, |
|||||
|
|
|
neither configure different wait-states to different External Memory Address |
|||||
|
|
|
sections. |
|||||
|
Pin Descriptions |
|
|
|
|
|
|
|
|
VCC |
Digital supply voltage. |
||||||
|
GND |
Ground. |
||||||
|
Port A (PA7..PA0) |
Port A is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each |
||||||
|
|
|
bit). The Port A output buffers have symmetrical drive characteristics with both high sink |
|||||
|
|
|
and source capability. As inputs, Port A pins that are externally pulled low will source |
|||||
|
|
|
current if the pull-up resistors are activated. The Port A pins are tri-stated when a reset |
|||||
|
|
|
condition becomes active, even if the clock is not running. |
|||||
|
|
|
Port A also serves the functions of various special features of the ATmega128 as listed |
|||||
|
|
|
on page 68. |
|||||
|
Port B (PB7..PB0) |
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each |
||||||
|
|
|
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. |
|||||
|
|
|
Port B also serves the functions of various special features of the ATmega128 as listed |
|||||
|
|
|
on page 69. |
|||||
|
Port C (PC7..PC0) |
Port C is an 8-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. |
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
|
2467B–09/01 |
|
|
|
|
|||
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Port C also serves the functions of special features of the ATmega128 as listed on page |
||||
|
|
|
72. In ATmega103 compatibility mode, Port C is output only, and the port C pins are not |
||||
|
|
|
tri-stated when a reset condition becomes active. |
||||
Port D (PD7..PD0) |
Port D is an 8-bit bidirectional 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 ATmega128 as listed |
||||
|
|
|
on page 73. |
||||
Port E (PE7..PE0) |
Port E is an 8-bit bidirectional I/O port with internal pull-up resistors (selected for each |
||||||
|
|
|
bit). The Port E output buffers have symmetrical drive characteristics with both high sink |
||||
|
|
|
and source capability. As inputs, Port E pins that are externally pulled low will source |
||||
|
|
|
current if the pull-up resistors are activated. The Port E pins are tri-stated when a reset |
||||
|
|
|
condition becomes active, even if the clock is not running. |
||||
|
|
|
Port E also serves the functions of various special features of the ATmega128 as listed |
||||
|
|
|
on page 76. |
||||
Port F (PF7..PF0) |
Port F serves as the analog inputs to the A/D Converter. |
||||||
|
|
|
Port F also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. |
||||
|
|
|
Port pins can provide internal pull-up resistors (selected for each bit). The Port F output |
||||
|
|
|
buffers have symmetrical drive characteristics with both high sink and source capability. |
||||
|
|
|
As inputs, Port F pins that are externally pulled low will source current if the pull-up |
||||
|
|
|
resistors are activated. The Port F pins are tri-stated when a reset condition becomes |
||||
|
|
|
active, even if the clock is not running. If the JTAG interface is enabled, the pull-up resis- |
||||
|
|
|
tors on pins PF7(TDI), PF5(TMS) and PF4(TCK) will be activated even if a reset occurs. |
||||
|
|
|
Port F also serves the functions of the JTAG interface. |
||||
|
|
|
In ATmega103 compatibility mode, Port F is an input Port only. |
||||
Port G (PG4..PG0) |
Port G is a 5-bit bidirectional I/O port with internal pull-up resistors (selected for each |
||||||
|
|
|
bit). The Port G output buffers have symmetrical drive characteristics with both high sink |
||||
|
|
|
and source capability. As inputs, Port G pins that are externally pulled low will source |
||||
|
|
|
current if the pull-up resistors are activated. The Port G pins are tri-stated when a reset |
||||
|
|
|
condition becomes active, even if the clock is not running. |
||||
|
|
|
Port G also serves the functions of various special features. |
||||
|
|
|
The port G pins are tri-stated when a reset condition becomes active, even if the clock is |
||||
|
|
|
not running. |
||||
|
|
|
In ATmega103 compatibility mode, these pins only serves as strobes signals to the |
||||
|
|
|
external memory as well as input to the 32 kHz oscillator, and the pins are initialized to |
||||
|
|
|
PG0 = 1, PG1 = 1, and PG2 = 0 asynchronously when a reset condition becomes active, |
||||
|
|
|
even if the clock is not running. PG3 and PG4 are oscillator pins. |
||||
|
|
|
Reset input. A low level on this pin for longer than the minimum pulse length will gener- |
||||
RESET |
|||||||
|
|
|
ate a reset, even if the clock is not running. The minimum pulse length is given in Table |
||||
|
|
|
19 on page 46. Shorter pulses are not guaranteed to generate a reset. |
||||
XTAL1 |
Input to the inverting oscillator amplifier and input to the internal clock operating circuit. |
6 ATmega128(L)
2467B–09/01
|
|
|
ATmega128(L) |
|
|
|
|
||
|
|
|
||
|
|
|
|
|
XTAL2 |
Output from the inverting oscillator amplifier. |
|||
AVCC |
This is the supply voltage pin for Port F and the A/D Converter. It should be externally |
|||
|
|
connected to VCC, even if the ADC is not used. If the ADC is used, it should be con- |
||
|
|
nected to VCC through a low-pass filter. |
||
AREF |
This is the analog reference pin for the A/D Converter. |
|||
PEN |
This is a programming enable pin for the serial programming mode. By holding this pin |
|||
|
|
low during a power-on reset, the device will enter the serial programming mode. |
PEN |
|
|
|
has no function during normal operation. |
About Code
Examples
This datasheet contains simple code examples that briefly show how to use various 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 definitions in the header files and interrupt handling in C is compiler dependent. Please confirm with the C compiler documentation for more details.
7
2467B–09/01