12
ATmega161(L)
1228B–09/01
SRAM Data Memory
Figure 8 shows how the ATmega161 SRAM memory is organized.
Figure 8.
SRAM Organization
The lower 1120 data memory locations address the register file, the I/O memory and the
internal data SRAM. The first 96 locations address the register file and I/O memory and
the next 1K locations address the internal data SRAM. An optional external data mem-
ory device can be placed in the same SRAM memory space. This memory device will
occupy the locations following the internal SRAM and up to as much as 64K - 1,
depending on external memory size.
When the addresses accessing the data memory space exceed the internal data SRAM
locations, the memory device is accessed using the same instructions as for the internal
data SRAM access. When the internal data space is accessed, the read and write
strobe pins (RD and WR) are inactive during the whole access cycle. External memory
operation is enabled by setting the SRE bit in the MCUCR register. See “Interface to
External Memory” on page 82 for details.
Accessing external memory takes one additional clock cycle per byte compared to
access of the internal SRAM. This means that the commands LD, ST, LDS, STS,
PUSH, and POP take one additional clock cycle. If the stack is placed in external mem-
ory, interrupts, subroutine calls and returns take two clock cycles extra because the 2-
byte program counter is pushed and popped. When external memory interface is used
with wait state, two additional clock cycles are used per byte. This has the following
effect: Data transfer instructions take two extra clock cycles, whereas interrupt, subrou-
tine calls and returns will need four clock cycles more than specified in the Instruction
Set manual.
Register File
Data Address Space
R0
$0000
R1
$0001
R2
$0002
…
…
R29
$001D
R30
$001E
R31
$001F
I/O Registers
$00
$0020
$01
$0021
$02
$0022
…
…
$3D
$005D
$3E
$005E
$3F
$005F
Internal SRAM
$0060
$0061
…
$045E
$045F