Professional Documents
Culture Documents
This example demonstrates the configuration required to bank switch using one 256 KByte
EPROM and four 64 KByte banks. The following figure illustrates the hardware schematic.
The following figure illustrates the memory map for this example.
One 256 KByte EPROM is used in this hardware configuration. Bank switching is implemented
using two bank select address lines (Port 1.5 and Port 3.3). The configuration file
(L51_BANK.A51) is configured as follows:
The section in L51_BANK.A51 that begins with IF ?B_MODE = 4 defines the code that
switches code banks. This section must be configured as follows:
Add the following to your startup code (STARTUP.A51) to ensure that the CPU starts in a
defined state at reset:
MOV SP,#?STACK-1
JMP ?C_START
The linker automatically adjusts the size of the common area places copies of it into each bank.
This makes the contents of all code banks identical in the address range of the common area.
The BANKAREA directive is not required (the default address range is 0-0xFFFF).
The following schematic shows hardware that has a 32 KByte common area and seven
32 KByte code banks. A single EPROM is used for all code space. Due to the address decoding
logic, code bank 0 is identical to the common area. Therefore, it should not be used by the
application.
This design provides 256 KBytes of xdata memory that is mapped like the code memory but is
accessed using the /RD and /WR lines (instead of the /PSEN line). The xdata space may be
used for variable banking.
The following figure illustrates the memory map for this example.
You must not use code bank 0 in your application (this memory is identical to the
common area). Therefore, no module of your application may be assigned to code bank
0.
HDATA (X:0x18000-X:0x1FFFF,X:0x28000-X:0x2FFFF,
X:0x38000-X:0x3FFFF,X:0x48000-X:0x4FFFF,
X:0x58000-X:0x5FFFF,X:0x68000-X:0x6FFFF,
X:0x78000-X:0x7FFFF),
HCONST (C:0x18000-C:0x1FFFF,C:0x28000-C:0x2FFFF,
C:0x38000-C:0x3FFFF,C:0x48000-C:0x4FFFF,
C:0x58000-C:0x5FFFF,C:0x68000-C:0x6FFFF,
C:0x78000-C:0x7FFFF))
XDATA Port
A latch or I/O device mapped into the XDATA space may be used to extend the address lines of
the 8051 device. The following example illustrates hardware that uses a latch mapped into the
XDATA space to address a 512 KByte EPROM.
The following figure illustrates the memory map for this example.
The linker automatically adjusts the size of the common area places copies of it into each bank.
This makes the contents of all code banks identical in the address range of the common area.
The BANKAREA directive is not required (the default address range is 0-0xFFFF).
5
On-chip ROM
Many 8051 derivatives have SFRs that configure on-chip code space which you may use to
introduce code banking to existing hardware designs.
For example, if your hardware uses a Dallas 80C320 (ROM-less device) and an external 64
KByte ROM, you may increase the code space of this design with a Dallas 80C520 which offers
16 KBytes of on-chip ROM. The Dallas 520 has a ROMSIZE SFR which enables or disables the
16K on-chip ROM block.
The figure on the right shows the memory layout for such a configuration.
The following settings in the code banking configuration file (L51_BANK.A51) are required.
The section in L51_BANK.A51 that begins with IF ?B_MODE = 4 defines the code that
switches code banks. This section must be configured as follows:
Add the following to your startup code (STARTUP.A51) to ensure that the CPU starts in a
defined state at reset:
MOV SP,#?STACK-1
JMP ?C_START