atmega128.pdf

(6209 KB) Pobierz
ATmega128
Features
High-performance, Low-power AVR ® 8-bit Microcontroller
Advanced RISC Architecture
– 133 Powerful Instructions – Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers + Peripheral Control Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16 MHz
– On-chip 2-cycle Multiplier
High Endurance Non-volatile Memory segments
– 128K Bytes of In-System Self-programmable Flash program memory
– 4K Bytes EEPROM
– 4K Bytes Internal SRAM
– Write/Erase cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/100 years at 25 ° C (1)
– Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
– Up to 64K Bytes Optional External Memory Space
– Programming Lock for Software Security
– SPI Interface for In-System Programming
JTAG (IEEE std. 1149.1 Compliant) Interface
– Boundary-scan Capabilities According to the JTAG Standard
– Extensive On-chip Debug Support
– Programming of Flash, EEPROM, Fuses and Lock Bits through the JTAG Interface
Peripheral Features
– Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
– Two Expanded 16-bit Timer/Counters with Separate Prescaler, Compare Mode and
Capture Mode
– Real Time Counter with Separate Oscillator
– Two 8-bit PWM Channels
– 6 PWM Channels with Programmable Resolution from 2 to 16 Bits
– Output Compare Modulator
– 8-channel, 10-bit ADC
8 Single-ended Channels
7 Differential Channels
2 Differential Channels with Programmable Gain at 1x, 10x, or 200x
– Byte-oriented Two-wire Serial Interface
– Dual Programmable Serial USARTs
– Master/Slave SPI Serial Interface
– Programmable Watchdog Timer with On-chip Oscillator
– On-chip Analog Comparator
Special Microcontroller Features
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated RC Oscillator
– External and Internal Interrupt Sources
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby, and
Extended Standby
– Software Selectable Clock Frequency
– ATmega103 Compatibility Mode Selected by a Fuse
– Global Pull-up Disable
I/O and Packages
– 53 Programmable I/O Lines
– 64-lead TQFP and 64-pad QFN/MLF
Operating Voltages
– 2.7 - 5.5V ATmega128L
– 4.5 - 5.5V ATmega128
Speed Grades
– 0 - 8 MHz ATmega128L
– 0 - 16 MHz ATmega128
8-bit
Microcontroller
with 128K Bytes
In-System
Programmable
Flash
ATmega128
ATmega128L
Note: Not recommended for new
designs.
Rev. 2467S–AVR–07/09
245848261.252.png 245848261.263.png 245848261.274.png 245848261.285.png 245848261.001.png 245848261.012.png 245848261.023.png
 
Pin
Configurations
Figure 1. Pinout ATmega128
PEN
RXD0/(PDI) PE0
(TXD0/PDO) PE1
(XCK0/AIN0) PE2
(OC3A/AIN1) PE3
(OC3B/INT4) PE4
(OC3C/INT5) PE5
(T3/INT6) PE6
(ICP3/IN T7 ) PE7
(SS) PB0
(SCK) PB1
(MOSI) PB2
(MISO) PB3
(OC0) PB4
(OC1A) PB5
(OC1B) PB6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
PA3 (AD3)
PA4 (AD4)
PA5 (AD5)
PA6 (AD6)
PA7 (AD7)
PG2(ALE)
PC7 (A15)
PC6 (A14)
PC5 (A13)
PC4 (A12)
PC3 (A11)
PC2 (A10)
PC1 (A9)
PC0 (A8 )
PG1( RD )
PG0(WR)
Note: The Pinout figure applies to both TQFP and MLF packages. The bottom pad under the QFN/MLF
package should be soldered to ground.
Overview
The ATmega128 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC
architecture. By executing powerful instructions in a single clock cycle, the ATmega128
achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize
power consumption versus processing speed.
2
ATmega128
2467S–AVR–07/09
245848261.044.png 245848261.055.png 245848261.066.png 245848261.077.png 245848261.088.png 245848261.099.png 245848261.110.png 245848261.121.png 245848261.132.png 245848261.143.png
 
ATmega128
Block Diagram
Figure 2. Block Diagram
PF0 - PF7
PA0 - PA7
PC0 - PC7
VCC
GND
PORTF DRIVERS
PORTA DRIVERS
PORTC DRIVERS
DATA REGISTER
PORTF
DATA DIR.
REG. PORTF
DATA REGISTER
PORTA
DATA DIR.
REG. PORTA
DATA REGISTER
PORTC
DATA DIR.
REG. PORTC
8-BIT DATA BUS
AVCC
CALIB. OSC
INTERNAL
OSCILLATOR
AGND
ADC
AREF
OSCILLATOR
JTAG TAP
PROGRAM
COUNTER
STACK
POINTER
WATCHDOG
TIMER
OSCILLATOR
ON-CHIP DEBUG
PROGRAM
FLASH
SRAM
MCU CONTROL
REGISTER
TIMING AND
CONTROL
BOUNDARY-
SCAN
INSTRUCTION
REGISTER
GENERAL
PURPOSE
REGISTERS
TIMER/
COUNTERS
X
PROGRAMMING
LOGIC
PEN
INSTRUCTION
DECODER
Y
INTERRUPT
UNIT
Z
CONTROL
LINES
ALU
EEPROM
STATUS
REGISTER
USART0
SPI
USART1
TWO-WIRE SERIAL
INTERFACE
DATA REGISTER
PORTE
DATA DIR.
REG. PORTE
DATA REGISTER
PORTB
DATA DIR.
REG. PORTB
DATA REGISTER
PORTD
DATA DIR.
REG. PORTD
DATA REG.
PORTG
DATA DIR.
REG. PORTG
PORTE DRIVERS
PORTB DRIVERS
PORTD DRIVERS
PORTG DRIVERS
PE0 - PE7
PB0 - PB7
PD0 - PD7
PG0 - PG4
3
2467S–AVR–07/09
245848261.164.png 245848261.175.png 245848261.186.png 245848261.197.png 245848261.208.png 245848261.219.png 245848261.223.png 245848261.224.png 245848261.225.png 245848261.226.png 245848261.227.png 245848261.228.png 245848261.229.png 245848261.230.png 245848261.231.png 245848261.232.png 245848261.233.png 245848261.234.png 245848261.235.png 245848261.236.png 245848261.237.png 245848261.238.png 245848261.239.png 245848261.240.png 245848261.241.png 245848261.242.png 245848261.243.png 245848261.244.png 245848261.245.png 245848261.246.png 245848261.247.png 245848261.248.png 245848261.249.png 245848261.250.png 245848261.251.png 245848261.253.png 245848261.254.png 245848261.255.png 245848261.256.png 245848261.257.png 245848261.258.png 245848261.259.png 245848261.260.png 245848261.261.png 245848261.262.png 245848261.264.png 245848261.265.png 245848261.266.png 245848261.267.png 245848261.268.png 245848261.269.png 245848261.270.png 245848261.271.png 245848261.272.png 245848261.273.png 245848261.275.png 245848261.276.png 245848261.277.png 245848261.278.png 245848261.279.png 245848261.280.png 245848261.281.png 245848261.282.png 245848261.283.png 245848261.284.png 245848261.286.png 245848261.287.png 245848261.288.png 245848261.289.png 245848261.290.png 245848261.291.png 245848261.292.png 245848261.293.png 245848261.294.png 245848261.295.png 245848261.002.png 245848261.003.png 245848261.004.png 245848261.005.png 245848261.006.png 245848261.007.png 245848261.008.png 245848261.009.png 245848261.010.png 245848261.011.png 245848261.013.png 245848261.014.png 245848261.015.png 245848261.016.png 245848261.017.png 245848261.018.png 245848261.019.png 245848261.020.png 245848261.021.png 245848261.022.png 245848261.024.png 245848261.025.png 245848261.026.png 245848261.027.png 245848261.028.png 245848261.029.png 245848261.030.png 245848261.031.png 245848261.032.png 245848261.033.png 245848261.034.png 245848261.035.png 245848261.036.png 245848261.037.png 245848261.038.png 245848261.039.png 245848261.040.png 245848261.041.png 245848261.042.png 245848261.043.png 245848261.045.png 245848261.046.png 245848261.047.png 245848261.048.png 245848261.049.png 245848261.050.png 245848261.051.png 245848261.052.png 245848261.053.png 245848261.054.png 245848261.056.png 245848261.057.png 245848261.058.png 245848261.059.png 245848261.060.png 245848261.061.png 245848261.062.png 245848261.063.png 245848261.064.png 245848261.065.png 245848261.067.png 245848261.068.png 245848261.069.png 245848261.070.png 245848261.071.png 245848261.072.png 245848261.073.png 245848261.074.png 245848261.075.png 245848261.076.png 245848261.078.png 245848261.079.png 245848261.080.png 245848261.081.png 245848261.082.png 245848261.083.png 245848261.084.png 245848261.085.png 245848261.086.png 245848261.087.png 245848261.089.png 245848261.090.png 245848261.091.png 245848261.092.png 245848261.093.png 245848261.094.png 245848261.095.png 245848261.096.png 245848261.097.png 245848261.098.png 245848261.100.png 245848261.101.png 245848261.102.png 245848261.103.png 245848261.104.png 245848261.105.png 245848261.106.png 245848261.107.png 245848261.108.png 245848261.109.png 245848261.111.png 245848261.112.png 245848261.113.png 245848261.114.png 245848261.115.png 245848261.116.png 245848261.117.png 245848261.118.png 245848261.119.png 245848261.120.png 245848261.122.png 245848261.123.png 245848261.124.png 245848261.125.png 245848261.126.png 245848261.127.png 245848261.128.png 245848261.129.png 245848261.130.png 245848261.131.png 245848261.133.png 245848261.134.png 245848261.135.png 245848261.136.png 245848261.137.png 245848261.138.png 245848261.139.png 245848261.140.png 245848261.141.png 245848261.142.png 245848261.144.png 245848261.145.png 245848261.146.png 245848261.147.png 245848261.148.png 245848261.149.png 245848261.150.png 245848261.151.png 245848261.152.png 245848261.153.png 245848261.154.png 245848261.155.png 245848261.156.png 245848261.157.png 245848261.158.png 245848261.159.png 245848261.160.png 245848261.161.png 245848261.162.png 245848261.163.png 245848261.165.png 245848261.166.png 245848261.167.png 245848261.168.png 245848261.169.png 245848261.170.png 245848261.171.png 245848261.172.png 245848261.173.png 245848261.174.png 245848261.176.png 245848261.177.png 245848261.178.png 245848261.179.png 245848261.180.png 245848261.181.png 245848261.182.png 245848261.183.png 245848261.184.png 245848261.185.png 245848261.187.png 245848261.188.png 245848261.189.png 245848261.190.png 245848261.191.png 245848261.192.png 245848261.193.png 245848261.194.png 245848261.195.png 245848261.196.png 245848261.198.png 245848261.199.png 245848261.200.png 245848261.201.png 245848261.202.png 245848261.203.png 245848261.204.png 245848261.205.png 245848261.206.png 245848261.207.png 245848261.209.png 245848261.210.png 245848261.211.png 245848261.212.png 245848261.213.png 245848261.214.png 245848261.215.png 245848261.216.png
The AVR core combines a rich instruction set with 32 general purpose working registers. All the
32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent
registers to be accessed in one single instruction executed in one clock cycle. The resulting
architecture is more code efficient while achieving throughputs up to ten times faster than con-
ventional CISC microcontrollers.
The ATmega128 provides the following features: 128K bytes of In-System Programmable Flash
with Read-While-Write capabilities, 4K bytes EEPROM, 4K bytes SRAM, 53 general purpose I/O
lines, 32 general purpose working registers, Real Time Counter (RTC), four flexible Timer/Coun-
ters with compare modes and PWM, 2 USARTs, a byte oriented Two-wire Serial Interface, an 8-
channel, 10-bit ADC with optional differential input stage with programmable gain, programma-
ble Watchdog Timer with Internal Oscillator, an SPI serial port, IEEE std. 1149.1 compliant
JTAG test interface, also used for accessing the On-chip Debug system and programming and
six software selectable power saving modes. The Idle mode stops the CPU while allowing the
SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning. The Power-down
mode saves the register contents but freezes the Oscillator, disabling all other chip functions
until the next interrupt or Hardware Reset. In Power-save mode, the asynchronous timer contin-
ues to run, allowing the user to maintain a timer base while the rest of the device is sleeping.
The ADC Noise Reduction mode stops the CPU and all I/O modules except Asynchronous
Timer and ADC, to minimize switching noise during ADC conversions. In Standby mode, the
Crystal/Resonator Oscillator is running while the rest of the device is sleeping. This allows very
fast start-up combined with low power consumption. In Extended Standby mode, both the main
Oscillator and the Asynchronous Timer continue to run.
The device is manufactured using Atmel’s high-density nonvolatile memory technology. The On-
chip ISP Flash allows the program memory to be reprogrammed in-system through an SPI serial
interface, by a conventional nonvolatile memory programmer, or by an On-chip Boot program
running on the AVR core. The boot program can use any interface to download the application
program in the application Flash memory. Software in the Boot Flash section will continue to run
while the Application Flash section is updated, providing true Read-While-Write operation. By
combining an 8-bit RISC CPU with In-System Self-Programmable Flash on a monolithic chip,
the Atmel ATmega128 is a powerful microcontroller that provides a highly flexible and cost effec-
tive solution to many embedded control applications.
The ATmega128 AVR is supported with a full suite of program and system development tools
including: C compilers, macro assemblers, program debugger/simulators, in-circuit emulators,
and evaluation kits.
ATmega103 and
ATmega128
Compatibility
The ATmega128 is a highly complex microcontroller where the number of I/O locations super-
sedes the 64 I/O locations reserved in the AVR instruction set. To ensure backward compatibility
with the ATmega103, all I/O locations present in ATmega103 have the same location in
ATmega128. Most additional I/O locations are added in an Extended I/O space starting from $60
to $FF, (i.e., in the ATmega103 internal RAM space). These locations can be reached by using
LD/LDS/LDD and ST/STS/STD instructions only, not by using IN and OUT instructions. The relo-
cation of the internal RAM space may still be a problem for ATmega103 users. Also, the
increased number of interrupt vectors might be a problem if the code uses absolute addresses.
To solve these problems, an ATmega103 compatibility mode can be selected by programming
the fuse M103C. In this mode, none of the functions in the Extended I/O space are in use, so the
internal RAM is located as in ATmega103. Also, the Extended Interrupt vectors are removed.
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.
4
ATmega128
2467S–AVR–07/09
245848261.217.png 245848261.218.png 245848261.220.png
ATmega128
ATmega103
Compatibility Mode
By programming the M103C fuse, the ATmega128 will be compatible with the ATmega103
regards to RAM, I/O pins and interrupt vectors as described above. However, some new fea-
tures in ATmega128 are not available in this compatibility mode, these features are listed below:
One USART instead of two, Asynchronous mode only. Only the eight least significant bits of
the Baud Rate Register is available.
One 16 bits Timer/Counter with two compare registers instead of two 16-bit Timer/Counters
with three compare registers.
Two-wire serial interface is not supported.
Port C is output only.
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.
In addition, there are some other minor differences to make it more compatible to ATmega103:
Only EXTRF and PORF exists in MCUCSR.
Timed sequence not required for Watchdog Time-out change.
External Interrupt pins 3 - 0 serve as level interrupt only.
USART has no FIFO buffer, so data overrun comes earlier.
Unused I/O bits in ATmega103 should be written to 0 to ensure same operation in ATmega128.
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
73 .
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
74 .
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
5
2467S–AVR–07/09
245848261.221.png 245848261.222.png
Zgłoś jeśli naruszono regulamin