Keil Logo

Configuration

You must define some aspects of your hardware design for the linker so it can create a code banking program that works on your target system. Specifically, you must specify the area of memory where code banks overlap and the number of code banks your hardware provides and how they are switched.

The linker's BANKAREA directive allows you to specify the memory address range that code banks occupy.

All other parameters are specified in one of the following configuration files (which are located in the \KEIL\C51\LIB folder):

  • L51_BANK.A51 for classic 8051 devices.
  • L51IBANK.A51 for devices based on the Mentor M8051EW core.
  • MX51BANK.A51 for Philips 51MX devices (this requires the CX51 Compiler and LX51 Linker which are included only in the PK51 Professional Developer's Kit).

Following are the configuration settings available in the configuration file:

Name Description
?B_NBANKS

This option specifies the number of code banks. The number of code banks implies the number of additional address lines required. Only values below are allowed for ?B_NBANKS:

?B_NBANKS
Code Banks
Required
Address Lines
2 1
4 2
8 3
16 4
32 5
64 6
?B_MODE This option specifies where additional address lines originate.
  • 0 indicates a standard 8051 I/O port.
  • 1 indicates an XDATA memory-mapped port.
  • 2 indicates an address line on a Philips 51MX device.
  • 4 indicates user-defined bank-switching logic.
?B_RTX This option specifies whether or not the application uses RTX51 Full (which only works with ?B_MODE 0 and 1).
  • 0 indicates RTX51 Full is not used.
  • 1 indicates RTX51 Full is used.
?B_VARBANKING This option specifies whether or not variable banking in XDATA and CODE memory is supported.
  • 0 indicates variable banking is not used.
  • 1 indicates variable banking is used.
?B_RST_BANK This option specifies the default bank that is selected on CPU is reset. This setting is used by the linker to reduce the number of entries in the inter-bank call table. The value 0xFF disables this optimization.

Note

  • Copy the code banking configuration file to your project folder and make changes to the copy. Be sure to include it in your project.
  • The Ax51 Assembler is required to assemble the configuration file.

The following additional public symbols are provided by the code banking configuration file.

Name Description
?B_CURRENTBANK Is a memory location in the DATA or SFR memory, which contains the currently selected memory bank. This memory location can be read for debugging. A modification of the memory location, however, does not cause  bank switching in most cases. Only required bits, based on setting of ?B_NBANKS and ?B_FIRSTBIT, are valid in this memory location. The bits, which are not required, must be masked out with a corresponding mask.
SWITCHBANK Is a Cx51 compatible function which allows the bank address to be selected by the user program. This function can be used for bank switching if the constant memory is too small. Note that this C function can be called only from code in the common area. It may be invoked as follows:
extern void switchbank (unsigned char bank_number);
.
.
.
      switchbank (0);
.
.
.

Note

  • For extended 8051 devices, there are several Application Notes that explain banking and memory configurations.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.