Two 8-Bit Timer/Counters with Separate Prescaler and PWM
•
One 16-Bit Timer/Counter with Separate Prescaler, Compare, Capture Modes and
Dual 8-, 9- or 10-Bit PWM
•
Programmable Watchdog Timer with On-Chip Oscillator
•
On-Chip Analog Comparator
•
8-Channel, 10-Bit ADC
•
Low Power Idle, Power Save and Power Down Modes
•
Software Selectable Clock Frequency
•
Programming Lock for Software Security
8-Bit
Microcontroller
with 64K/128K
Bytes In-System
Programmable
Flash
ATmega603
ATmega603L
ATmega103
Pin Configuration
ATmega103L
TQFP
Preliminary
A Tmega103/L
A Tmega103/L
Rev. 0945BS–09/98
Note:This is a summ ary document. F or the co mplete 9 2
page document, please visit our web site at
www.atmel.com
and request literature #0945B.
or e-mail at
literature@atmel .com
1
Block Diagram
Figure 1.
AVCC
AGND
AREF
The ATmega603/103 Block Diagram
VCC
GND
PORTF BUFFERS
ANALOG MUXADC
PROGRAM
COUNTER
PROGRAM
FLASH
INSTRUCTION
REGISTER
INSTRUCTION
DECODER
CONTROL
LINES
PORTA DRIVER/BUFFERS
DATAREGISTER
PORTA
STACK
POINTER
SRAM
GENERAL
PURPOSE
REGISTERS
X
Y
Z
ALU
STATUS
REGISTER
PA0 - PA7PF0 - PF7
DATADIR.
REG. PORTA
INTERNAL
OSCILLATOR
WATCHDOG
MCU CONTROL
REGISTER
COUNTERS
INTERRUPT
EEPROM
PROGRAMMING
TIMER
TIMER/
UNIT
LOGIC
8-BIT DATA BUS
OSCILLATOR
OSCILLATOR
TIMING AND
PC0 - PC7
PORTC DRIVERS
DATAREGISTER
PORTC
CONTROL
XTAL1
XTAL1
TOSC2
TOSC1
RESET
ALE
WR
RD
PEN
SPI
ANALOG
COMPARATOR
DATAREGISTER
+
-
PORTE
DATADIR.
REG. PORTE
DATAREGISTER
PORTB
PORTB DRIVER/BUFFERSPORTE DRIVER/BUFFERS
PB0 - PB7PE0 - PE7
Description
The ATmega603/103 is a low-power CMOS 8-bit microcon-
AVR
troller based on the
executing powerful instructions in a single clock cycle, the
ATmega603/103 achieves th roughputs approaching 1
MIPS per MHz allowing the system designer to optimize
power consumption versus processing speed.
The AVR core is b ased o n an enh anced RISC ar chite ctur e
that combines a rich instruction set with 32 general purpose
working regist ers. All the 32 regi sters are directl y connected to the Arithmetic Logic Unit (ALU), allowing two
independent regist ers to be accessed in one single instruction executed in one c lock cycl e. The resu lting archite ctu re
enhanced RISC architecture. By
UART
DATADIR.
REG. PORTB
DATAREGISTER
PORTD
PORTD DRIVER/BUFFERS
PD0 - PD7
DATADIR.
REG. PORTD
VCC
GND
is more code efficient while achieving throughputs up to ten
times faster than conventional CISC microcontrollers.
The ATmega603/103 provides the following features:
64K/128K bytes of In-system Programmable Flash, 2K/4K
bytes EEPROM, 4K bytes SRAM , 32 general purpos e I/O
lines, 8 Input lines , 8 Output lines , 32 general pur pose
working registers, 4 flexible timer/counters with compare
modes and PWM, UART, programmable Watchdog Timer
with internal oscillator, an SPI serial port and three software
selectable pow er saving modes. T he Idle M ode sto ps the
CPU while allowing the SRAM, timer/counters, SPI port
and interrupt system to continue func tioning. The Power
2
ATmega603(L) and ATmega103(L)
ATmega603(L) and ATmega103(L)
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 timer
oscillator continues to run, allowing the user to maintain a
timer base while the rest of the device is sleeping.
The device is manufactured using A tmel’s high-density
non-volatile memory technology. The on-chip ISP Flash
allows the program memory to be reprogrammed in-system
through a serial interface or by a co nventional non volatile
memory programmer. By combining an 8-bit RISC CPU
with a large array of ISP Flash on a monolithic chip, the
Atmel ATmega603/103 is a powerful microcontroller that
provides a h ighly flexibl e and cost effective solution to
many embedded control appl ic ati on s.
The ATmega603/103 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.
Comparison Between ATmega 603 and
ATmega 103
The ATmega603 h as 64K bytes o f In-Sys tem Pro gramm able Flash, 2K bytes o f EEPROM, an d 4K bytes o f internal
SRAM. The ATmega603 does not have the ELPM instruction.
The ATmega103 has 128K bytes of In-System Programmable Flash, 4K bytes of EEPROM, and 4K bytes of internal SRAM. The ATmega10 3 has the ELPM instruct ion,
necessary to reach the upper half of the Flash memory for
constant table lookup.
Table 1 summarizes the dif ferent memory size s for the two
devices.
Port A is an 8-bit bi-directional I/O port. Port pins can provide internal pull-up resistors (selected for each bit). The
Port A output buffers can sink 20 mA and can drive LED
displays directly. When pins PA0 to PA7 are used as inputs
and are externally pull ed low, they will source c urrent if the
internal pull-up resistors are activated.
Port A serves as Multiplexed Address/Data bus when using
external SRAM.
Port B (PB7..PB0)
Port B is an 8-bi t b i-di r ect ion al I/O pin s wit h i nte rn al pu ll -up
resistors. The Port B output buffers can sink 20 mA. As
inputs, Port B pins that are externally pulled low, will source
current if the pull-up resistors are activated.
Port B also serves the functions of various special features.
Port C (PC7..PC0)
Port C is an 8- bi t Outp ut port . The Port C out put buf fer s can
sink 20 mA.
Port C also serv es as Ad dress ou tput wh en using extern al
SRAM.
Port D (PD7..PD0)
Port D is an 8-bit bi-directional I/O port with internal pull-up
resistors. The Port D output buffers can sink 20 mA. As
inputs, Port D pins that are external ly pul le d low will s our ce
current if the pull-up resistors are activated.
Port D also serves the functions of various special features.
Port E (PE7..PE0)
Port E is an 8-bit bi- directi onal I/O port with internal pull -up
resistors. The Port E output buffers can sink 20 mA. As
inputs, Port E pins t hat a re ex ter na lly p ull ed l ow w il l sour ce
current if the pull-up resistors are activated.
Port E also serves the functions of various special features.
Port F (PF7..PF0)
Port F is an 8-bi t Input port. P ort F al so serv es as the a nalog inputs for the ADC.
RESET
input. A low on this pin for two machine cy cles while the
oscillator is running resets the device.
XTAL1
Input to the inverting os cillator ampli fier and input to th e
internal clock operating circuit.
XTAL2
Output from the inverting oscillator amplifier
TOSC1
Input to the inverting Timer/Counter oscillator amplifier
TOSC2
Output from the inverting Timer/Counter oscillator amplifier
WR
External SRAM Write Strobe.
RD
External SRAM Read Strobe.
ALE
ALE is the Address Latch Enable used when the Ex ternal
Memory is enabled. The ALE strob e is used to latch the
low-order address (8 bits) into an address latch during the
3
first access cycl e, and the A D0-7 pins ar e used for data
during the second access cycle.
AV
CC
This is the supply voltage to the A/D Converter. It should be
externally connec ted to V
via a low-pass filter. See
CC
page 53 for details on operation of the ADC.
AREF
This is the analog reference input for the ADC converter.
For ADC operations, a voltage in the range AGND to AVCC
must be applied to this pin.
AGND
If the board has a sepa rate analog gr ound plane, th is pin
should be co nnect ed to this gr ound plane . Ot herwi se, connect to GND.
PEN
This is a programming enabl e pin for the low -voltage ser ial
programming mode. By holding this pin low during a poweron reset, the device will enter the serial programming
mode.
Crystal Oscillator
XTAL1 and XTAL2 are input and output, respectively, of an
inverting amplifier which can be configured for use as an
on-chip oscillator, as shown in Figure 2. Either a quartz
crystal or a ceramic resonator may be used. To drive the
device from an external clock source, XTAL2 should be left
unconnected while XTAL1 is driven as shown in Figure 3.
For the Timer Oscillator pins, O SC1 an d OSC2, t he cr ystal
is connected directly be twee n the pi ns . No ex ternal cap ac itors are needed. The oscillator is optimi zed for use with a
32,768Hz watch crys tal. A n e xt er nal cloc k sign al app li ed t o
this pin goes throug h the same a mplifier having a bandwidth of 256kHz. The external clock signal should therefore
be in the interval 0Hz - 256kHz.
Figure 2.
Oscillator Connec tion s
C2
XTAL2
C1
XTAL1
Figure 3.
External Clock Drive Configuration
NC
EXTERNAL
OSCILLATOR
SIGNAL
XTAL2
XTAL1
GND
AT mega603/103 Architectural Overview
The fast-access register file contains 32 x 8-bit general purpose working registers with a single clock cycle access
time. This means that during one single clock cycle, one
ALU (Arithmetic Logic Unit) operation is executed. Two
operands are output from the register file, the operation is
executed, and the result is stored back in the register file in one clock cycle.
Six of the 32 registers can be used as three 16-bit indirect
address register pointers for Data Space addressing enabling efficient address calculati ons. One of the three
address pointers is also used as the address pointer for the
constant table look up function. These added function registers are the 16-bit X-register, Y-register and Z-register.
The ALU supports arithmetic and logic functions b etween
registers or between a const ant and a r egist er. Si ngle re gister operations are also executed in the ALU. Figure 4
shows the ATmega603/103 AVR Enhanced RISC microcontroller architectu re .
In addition to the register operation, the conventional memory addressi ng mode s can be us ed on th e regi ster fil e as
well. This is e nabled by th e fact that t he register fil e is
assigned the 32 lowermost Data Space addresses, allowing them to be accessed as thou gh they were ordinary
memory locations.
The I/O memory space contains 64 addresse s for CPU
peripheral functions as Control Registers, Timer/Counters,
A/D-converters, an d other I/O func tions. The I/O M emory
can be accessed dir ectly, or as the Da ta Space loca tions
following those of the register file, $20 - $5F.
GND
4
ATmega603(L) and ATmega103(L)
ATmega603(L) and ATmega103(L)
Figure 4.
The ATmega603/103 AVR Enhanced RISC Architecture
AVR ATmega603/103 Architecture
32K/64K x 16
Program
Memory
Instruction
Register
Instruction
Decoder
Control Lines
Program
Counter
DirectAddressing
IndirectAddressing
Data Bus 8-bit
Status
and Test
32 x 8
General
Purpose
Registers
Peripherals
ALU
4K x 8
Data
SRAM
The AVR uses a Ha rvard archi tecture concep t - with separate memories and buses for prog ram and data. The program memory is executed with a single level pipelining.
While one instruction is being executed, the next instruction
is pre-fetched from the program memory. T his concept
enables instructions to be executed in every clock cycle.
The program memory is in-system programmable Flash
memory. With a few exceptions, AVR instructions have a
single 16-bit w ord format, me aning that ev ery program
memory address contains a single 16-bit instruction.
During interrupts a nd subr outine cal ls, the re turn addre ss
program counter (PC) is stored on the s tack. The stack is
effectively allocat ed in the g enera l data SRAM, a nd cons equently the stack size is only limited by the total SRAM size
and the usage of the SRA M. Al l us er pro gr ams mu st i nit ia lize the SP in the reset routine (before subroutines or interrupts are execute d). The 16-bit stack pointer SP is
read/write accessib le in the I/O spac e.
2K/4K x 8
EEPROM
The 4000 bytes data SRAM can be easily accessed
through the five different addressing modes supported in
the AVR architecture.
A flexible interrupt module has its control registers in the
I/O space with an additional global interrupt enable bit in
the status reg ister. All th e diffe rent int errupt s have a sepa rate interr upt vector i n the inter rupt vector table at the
beginning of the program memory. The different interrupts
have priority in accordance with their interrupt vector position. The lower the interrupt vector address, the higher the
priority.
The memory spaces in the AVR architecture are all l inear
and regular memory maps.
The General Purpose Register File
Figure 5 shows the structure of the 32 general purpose
working registers in the CPU.
MnemonicsOperandsDescriptionOperationFlags#Clocks
ARITHMETIC AND LOGIC INSTRUCTIONS
ADDRd, RrAdd two RegistersRd ← Rd + RrZ,C,N,V,H1
ADCRd, RrAdd with Carry two RegistersRd ← Rd + Rr + CZ,C,N,V,H1
ADIWRdl,KAdd Immediate to WordRdh:Rdl ← Rdh:Rdl + KZ,C,N,V,S2
SUBRd, RrSubtract two RegistersRd ← Rd - RrZ,C,N,V,H1
SUBIRd, KSubtract Constant from Register Rd ← Rd - KZ,C,N,V,H1
SBCRd, RrSubtract with Carry two RegistersRd ← Rd - Rr - CZ,C,N,V,H1
SBCIRd, KSubtract with Carry Constant from Reg.Rd ← Rd - K - CZ,C,N,V,H1
SBIWRdl,KSubtract Immediate from WordRdh:Rdl ← Rdh:Rdl - KZ,C,N,V,S2
ANDRd, RrLogical AND RegistersRd ← Rd • RrZ,N,V1
ANDIRd, KLogical AND Register and ConstantRd ← Rd • KZ,N,V1
ORRd, RrLogical OR RegistersRd ← Rd v RrZ,N,V1
ORIRd, KLogical OR Register and ConstantRd ← Rd v KZ,N,V1
EORRd, RrExclusive OR RegistersRd ← Rd ⊕ RrZ,N,V1
COMRdOne’s ComplementRd ← $FF - RdZ,C,N,V1
NEGRdTwo’s ComplementRd ← $00 - RdZ,C,N,V,H1
SBRRd,KSet Bit(s) in RegisterRd ← Rd v KZ,N,V1
CBRRd,KClear Bit(s) in RegisterRd ← Rd • ($FF - K)Z,N,V1
INCRdIncrementRd ← Rd + 1Z,N,V1
DECRdDecrementRd ← Rd - 1 Z,N,V1
TSTRdTest for Zero or MinusRd ← Rd • Rd Z,N,V1
CLRRdClear RegisterRd ← Rd ⊕ RdZ,N,V1
SERRdSet RegisterRd ← $FFNone1
BRANCH INSTRUCTIONS
RJMPkRelative JumpPC ← PC + k + 1None2
IJMPIndirect Jump to (Z)PC ← Z None2
JMPkDirect JumpPC ← kNone3
RCALLkRelative Subroutine Call PC ← PC + k + 1None3
ICALLIndirect Call to (Z)PC ← ZNone3
CALLkDirect Subroutine CallPC ← kNone4
RETSubroutine ReturnPC ← STACKNone4
RETIInterrupt ReturnPC ← STACKI4
CPSERd,RrCompare, Skip if Equalif (Rd = Rr) PC ← PC + 2 or 3None1 / 2
CPRd,RrCompareRd - RrZ, N,V,C,H1
CPCRd,RrCompare with CarryRd - Rr - CZ, N,V,C,H1
CPIRd,KCompare Register with ImmediateRd - KZ, N,V,C,H1
SBRCRr, bSkip if Bit in Register Clearedif (Rr(b)=0) PC ← PC + 2 or 3 None1 / 2
SBRSRr, bSkip if Bit in Register is Setif (Rr(b)=1) PC ← PC + 2 or 3None1 / 2
SBICP, bSkip if Bit in I/O Register Clearedif (P(b)=0) PC ← PC + 2 or 3 None1 / 2
SBISP, bSkip if Bit in I/O Register is Setif (P(b)=1) PC ← PC + 2 or 3None1 / 2
BRBSs, kBranch if Status Flag Setif (SREG(s) = 1) then PC←PC+k + 1None1 / 2
BRBCs, kBranch if Status Flag Clearedif (SREG(s) = 0) then PC←PC+k + 1None1 / 2
BREQ kBranch if Equal if (Z = 1) then PC ← PC + k + 1None1 / 2
BRNE kBranch if Not Equalif (Z = 0) then PC ← PC + k + 1None1 / 2
BRCS kBranch if Carry Setif (C = 1) then PC ← PC + k + 1None1 / 2
BRCC kBranch if Carry Clearedif (C = 0) then PC ← PC + k + 1None1 / 2
BRSH kBranch if Same or Higher if (C = 0) then PC ← PC + k + 1None1 / 2
BRLO kBranch if Lowerif (C = 1) then PC ← PC + k + 1None1 / 2
BRMI kBranch if Minusif (N = 1) then PC ← PC + k + 1None1 / 2
BRPL kBranch if Plus if (N = 0) then PC ← PC + k + 1None1 / 2
BRGE kBranch if Greater or Equal, Signedif (N ⊕ V= 0) then PC ← PC + k + 1None1 / 2
BRLT kBranch if Less Than Zero, Signedif (N ⊕ V= 1) then PC ← PC + k + 1None1 / 2
BRHS kBranch if Half Carry Flag Setif (H = 1) then PC ← PC + k + 1None1 / 2
BRHC kBranch if Half Carry Flag Clearedif (H = 0) then PC ← PC + k + 1None1 / 2
BRTS kBranch if T Flag Setif (T = 1) then PC ← PC + k + 1None1 / 2
BRTC kBranch if T Flag Clearedif (T = 0) then PC ← PC + k + 1None1 / 2
BRVS kBranch if Overflow Flag is Setif (V = 1) then PC ← PC + k + 1None1 / 2
BRVC kBranch if Overflow Flag is Clearedif (V = 0) then PC ← PC + k + 1None1 / 2
BRIE kBranch if Interrupt Enabledif ( I = 1) then PC ← PC + k + 1None1 / 2
BRID kBranch if Interrupt Disabledif ( I = 0) then PC ← PC + k + 1None1 / 2
7
ATmega603/103 Instruction Set Summary (Continued)
DATA TRANSFER INSTRUCTIONS
()
ELPM
MOVRd, RrMove Between RegistersRd ← RrNone1
LDIRd, KLoad ImmediateRd ← KNone1
LDRd, XLoad IndirectRd ← (X)None2
LDRd, X+Load Indirect and Post-Inc.Rd ← (X), X ← X + 1None2
LDRd, - XLoad Indirect and Pre-Dec.X ← X - 1, Rd ← (X)None2
LDRd, YLoad IndirectRd ← (Y)None2
LDRd, Y+Load Indirect and Post-Inc.Rd ← (Y), Y ← Y + 1None2
LDRd, - YLoad Indirect and Pre-Dec.Y ← Y - 1, Rd ← (Y)None2
LDDRd,Y+qLoad Indirect with DisplacementRd ← (Y + q)None2
LDRd, ZLoad Indirect Rd ← (Z)None2
LDRd, Z+Load Indirect and Post-Inc.Rd ← (Z), Z ← Z+1None2
LDRd, -ZLoad Indirect and Pre-Dec.Z ← Z - 1, Rd ← (Z)None2
LDDRd, Z+qLoad Indirect with DisplacementRd ← (Z + q)None2
LDSRd, kLoad Direct from SRAMRd ← (k)None2
STX, RrStore Indirect(X) ← RrNone2
STX+, RrStore Indirect and Post-Inc.(X) ← Rr, X ← X + 1None2
ST- X, RrStore Indirect and Pre-Dec.X ← X - 1, (X) ← RrNone2
STY, RrStore Indirect(Y) ← RrNone2
STY+, RrStore Indirect and Post-Inc.(Y) ← Rr, Y ← Y + 1None2
ST- Y, RrStore Indirect and Pre-Dec.Y ← Y - 1, (Y) ← RrNone2
STDY+q,RrStore Indirect with Displacement(Y + q) ← RrNone2
STZ, RrStore Indirect(Z) ← RrNone2
STZ+, RrStore Indirect and Post-Inc.(Z) ← Rr, Z ← Z + 1None2
ST-Z, RrStore Indirect and Pre-Dec.Z ← Z - 1, (Z) ← RrNone2
STDZ+q,RrStore Indirect with Displacement(Z + q) ← RrNone2
STSk, RrStore Direct to SRAM(k) ← RrNone2
LPMLoad Program MemoryR0 ← (Z)None3
INRd, PIn PortRd ← PNone1
OUTP, RrOut PortP ← RrNone1
PUSHRrPush Register on StackSTACK ← RrNone2
POPRdPop Register from StackRd ← STACKNone2
BIT AND BIT-TEST INSTRUCTIONS
SBIP,bSet Bit in I/O RegisterI/O(P,b) ← 1None2
CBIP,bClear Bit in I/O RegisterI/O(P,b) ← 0None2
LSLRdLogical Shift LeftRd(n+1) ← Rd(n), Rd(0) ← 0Z,C,N,V1
LSRRdLogical Shift RightRd(n) ← Rd(n+1), Rd(7) ← 0Z,C,N,V1
ROLRdRotate Left Through CarryRd(0)←C,Rd(n+1)← Rd(n),C←Rd(7)Z,C,N,V1
RORRdRotate Right Through CarryRd(7)←C,Rd(n)← Rd(n+1),C←Rd(0)Z,C,N,V1
ASRRdArithmetic Shift RightRd(n) ← Rd(n+1), n=0..6Z,C,N,V1
SWAPRdSwap NibblesRd(3..0)←Rd(7..4),Rd(7..4)←Rd(3..0)None1
BSETsFlag SetSREG(s) ← 1SREG(s)1
BCLRsFlag ClearSREG(s) ← 0 SREG(s)1
BSTRr, bBit Store from Register to TT ← Rr(b)T1
BLDRd, bBit load from T to RegisterRd(b) ← TNone1
SECSet CarryC ← 1C1
CLCClear CarryC ← 0 C1
SENSet Negative FlagN ← 1N1
CLNClear Negative FlagN ← 0 N1
SEZSet Zero FlagZ ← 1Z1
CLZClear Zero FlagZ ← 0 Z1
SEIGlobal Interrupt EnableI ← 1I1
CLIGlobal Interrupt DisableI ← 0 I1
SESSet Signed Test FlagS ← 1S1
CLSClear Signed Test FlagS ← 0 S1
SEVSet Twos Complement Overflow.V ← 1V1
CLVClear Twos Complement OverflowV ← 0 V1
SETSet T in SREGT ← 1T1
CLTClear T in SREGT ← 0 T1
SEHSet Half Carry Flag in SREGH ← 1H1
CLHClear Half Carry Flag in SREGH ← 0 H1
NOPNo OperationNone1
SLEEPSleep(see specific descr. for Sleep function)None3
WDRWatchdog Reset(see specific descr. for WD timer)None1
Extended Load Program MemoryR0 ← (Z+RAMPZ)None3
8
ATmega603(L) and ATmega103(L)
ATmega603(L) and ATmega103(L)
Ordering Information
Speed (MHz)Power SupplyOrdering CodePackageOperation Range