Basic Memory Map Note: The 8051 architecture provides a total of 64 KB of external address space when the processor is used in a shared program and data space configuration. Address in Binary Hex Address Use 1111xxxxxxxxxxxx FFFFh 1110xxxxxxxxxxxx 1101xxxxxxxxxxxx 1100xxxxxxxxxxxx 1011xxxxxxxxxxxx 1010xxxxxxxxxxxx 1001xxxxxxxxxxxx 1000xxxxxxxxxxxx 8000h SRAM (32KB) (32768 bytes) 0111xxxxxxxxxxxx 7FFFh 0110xxxxxxxxxxxx 6000h Peripherals (8KB) (8192 bytes) 0101xxxxxxxxxxxx 5FFFh 0100xxxxxxxxxxxx 0011xxxxxxxxxxxx 0010xxxxxxxxxxxx 0001xxxxxxxxxxxx 0000xxxxxxxxxxxx 0000h EPROM (24KB) (24576 bytes) Note: The upper address bits are used to decode the address space and to generate chip select signals for the various chips. For example, notice that address line A15 is high for all addresses assigned to the 32 KB SRAM, while all other address lines in that address space can be either high or low. Note: Although the EPROM contains 32KB of physical memory, only 24KB will actually be accessible when using this memory map. Increasing Addresses 64 KB of Address Space Embedded System Design Memory Map Details Linden H. McClure, Ph.D. 2003 2 Memory Map When Using MON51 Debug Monitor Note: The MON51 debug monitor distributed with the Dunfield Development Systems MICRO-C tools requires a license. Note: MON51 requires 80 bytes of external SRAM storage in order to support monitor features such as breakpoints. This particular memory map is historical in nature. There exist many MON51 EPROMs which have been programmed with the memory bounds set at $DFB0 and $DFFF. If you have your own copy of MON51 and are programming your own EPROM, you should adjust the memory map so that the MON51 variables are located between $FFB0 and $FFFF. This will provide more contiguous SRAM for your program variables. Note: When using a debug monitor to download code into SRAM, your hex record file must contain addresses which correspond to the SRAM addresses in your memory map. $FFFF $E000 $DFFF $DFB0 $DFAF $8000 $7FFF $6000 $5FFF $0ED6 $0ED5 $0000 Available for User Code and Variables (8KB or 8192 bytes) Available for User Code and Variables (24496 bytes) Available for User Code and Constants if MON51 EPROM is Reprogrammed (20779 bytes) MON51 Code (3797 bytes) Peripherals (8KB or 8192 bytes) MON51 Variables (80 bytes) Reset Vector is fixed at $0000. All Interrupt Vectors except Timer 1 are re-vectored to the beginning of SRAM. Interrupt handlers for all interrupts except Timer 1 can be located at beginning of SRAM. Embedded System Design Memory Map Details Linden H. McClure, Ph.D. 2003 3 Memory Map When Using PAULMON2 Debug Monitor Note: PAULMON2 is a free debug monitor available on the web. Equates at the beginning of C:\MC\LIB51\8051RLPC.ASM: ?RAM EQU $B000 Ext er nal DATA ( RAM) St ar t s her e ?RAMEND EQU $FFFF Ext er nal DATA ( RAM) Ends her e ORG $8000 CODE St ar t s her e i n RAM ( nor mal l y i n ROM) Note: When using a debug monitor to download code into SRAM, your hex record file must contain addresses which correspond to the SRAM addresses in your memory map. $FFFF $8000 $7FFF $6000 $5FFF $0F66 $0F65 $0000 Peripherals (8KB or 8192 bytes) Available for User Code and Constants or for PAULMON2 extensions if EPROM is Reprogrammed (~20635 bytes) PAULMON2 Core Code (~3941 bytes) Available for User Code and Variables (32 KB or 32768 bytes) Reset Vector is fixed at $0000. All Interrupt Vectors are re- vectored to the beginning of SRAM. Interrupt handlers for all interrupts can be located at beginning of SRAM. Embedded System Design Memory Map Details Linden H. McClure, Ph.D. 2003 4 Memory Map When Using MICRO-C (Compact Model) Without Debug Monitor Equates at the beginning of C:\MC\LIB51\8051RLPC.ASM: ?RAM EQU $8000 Ext er nal DATA ( RAM) St ar t s her e ?RAMEND EQU $FFFF Ext er nal DATA ( RAM) Ends her e ORG $0000 CODE St ar t s her e i n ROM Note: With this memory map, user code would be stored in EPROM, starting at address $0000. Note: The usage of memory space by the MICRO-C compiler depends on the MICRO-C memory model chosen and the addresses chosen in the corresponding memory model configuration file. When using the compact memory model, the 8051RLPC.ASM file is used. This file contains the initialization code which locates the uninitialized global variables, external stack, and external heap in the correct locations. Available for User Variables (32 KB or 32768 bytes) Available for User Code and Constants (24 KB or 24576 bytes) Peripherals (8 KB or 8192 bytes) $FFFF $8000 $7FFF $6000 $5FFF $0000 External Stack. Used for local variables. Referenced by the ?stack MICRO-C variable. Starts at top of SRAM and grows downward. Heap. Used for malloc's and to hold temporary strings. Referenced by the ?heap MICRO-C variable. Grows upward. Uninitialized MICRO-C global variables. Embedded System Design Memory Map Details Linden H. McClure, Ph.D. 2003 5 Memory Map When Using MICRO-C (Compact Model) With MON51 Equates at the beginning of C:\MC\LIB51\8051RLPC.ASM: ?RAM EQU $B000 Ext er nal DATA ( RAM) St ar t s her e ?RAMEND EQU $FFFF Ext er nal DATA ( RAM) Ends her e ORG $8000 CODE St ar t s her e i n RAM ( nor mal l y i n ROM) Note: With the above memory map, if user code ever exceeds 12288 bytes, problems will result at run time, since temporary values stored in RAM will overwrite any code which is present in RAM addresses higher than $AFFF. Symptoms of this problem include erratic program behavior which disappears if you comment out a function or section of code and then run the recompiled code. If code size exceeds 12288 bytes, ?RAM will need to be redefined to some higher value, such as $C000. The choice of the value for ?RAM depends on your particular application and its requirements for code space versus data space. If external stack space usage ever exceeds 8192 bytes, or if the heap ever grows past $DFAF, the MON51 variables will be overwritten and MON51 will stop working correctly. Note: This particular memory map is historical in nature. There exist many MON51 EPROMs which have been programmed with the memory bounds set at $DFB0 and $DFFF. If you have your own copy of MON51 and are programming your own EPROM, you should adjust the memory map so that the MON51 variables are located between $FFB0 and $FFFF and that ?RAMEND is set to $FFAF. This will provide more flexibility for various program requirements on heap space versus stack space. $FFFF $E000 $DFFF $DFB0 $DFAF $B000 $AFFF $8000 $7FFF $6000 $5FFF $0ED6 $0ED5 $0000 Peripherals (8 KB or 8192 bytes) Available for User Code (12288 bytes) Available for User Variables (12208 bytes) Available for User Code and Constants if MON51 EPROM is Reprogrammed (20779 bytes) MON51 Code (3797 bytes) Available for User Variables (8 KB or 8192 bytes) MON51 Variables (80 bytes) Reset Vector is fixed at $0000. All Interrupt Vectors except Timer 1 are re-vectored to the beginning of SRAM. Interrupt handlers for all interrupts except Timer 1 can be located at beginning of SRAM. External Stack. Grows downward. Heap. Grows upward. Uninitialized MICRO-C global variables. Embedded System Design Memory Map Details Linden H. McClure, Ph.D. 2003 6 Memory Map When Using MICRO-C (Compact Model) With PAULMON2 Equates at the beginning of C:\MC\LIB51\8051RLPC.ASM: ?RAM EQU $B000 Ext er nal DATA ( RAM) St ar t s her e ?RAMEND EQU $FFFF Ext er nal DATA ( RAM) Ends her e ORG $8000 CODE St ar t s her e i n RAM ( nor mal l y i n ROM) Note: With the above memory map, if user code ever exceeds 12288 bytes, problems will result at run time, since temporary values stored in RAM will overwrite any code which is present in RAM addresses higher than $AFFF. Symptoms of this problem include erratic program behavior which disappears if you comment out a function or section of code and then run the recompiled code. If code size exceeds 12288 bytes, ?RAM will need to be redefined to some higher value, such as $C000. The choice of the value for ?RAM depends on your particular application and its requirements for code space versus data space. $FFFF $B000 $AFFF $8000 $7FFF $6000 $5FFF $0F66 $0F65 $0000 Peripherals (8 KB or 8192 bytes) Available for User Code (12288 bytes) Available for User Code and Constants or for PAULMON2 extensions if EPROM is Reprogrammed (~20635 bytes) PAULMON2 Core Code (~3941 bytes) Available for User Variables (20480 bytes) Reset Vector is fixed at $0000. All Interrupt Vectors are re- vectored to the beginning of SRAM. Interrupt handlers for all interrupts can be located at beginning of SRAM. External Stack. Grows downward. Heap. Grows upward. Uninitialized MICRO-C global variables.