Keil Logo

BL51: LOCATING CONSTANT (CODE) VARIABLES IN A CODE BANK


Information in this article applies to:

  • C51 Version 5.50a
  • C51 Version 6.01

QUESTION

How do I locate a constant variable in a code bank? I have a source file with a table declared as follows:

unsigned char const code table [10] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };

When I compile and link, the functions in this source file are located in the correct bank, but the table is located in the common area.

ANSWER

When you compile a source file (for example MYCODE.C), the compiler creates program segments for your functions and code segments for your code-based variables.

Each function will be located in a segment named ?PR?function_name?source_file_name.

All code variables will be located in a segment named ?CO?source_file_name.

The linker has commands that let you automatically locate all of the program code from a source file in a code bank. However, the code segments from that file are NOT located in the code bank. You must do that manually.

To locate the code variables in a particular bank, link using a similar command line:

bl51 ... bankarea (0x8000,0xFFFF) BANK0(?CO?MYCODE (0x8000)) ...

or

bl51 ... bankarea (0x8000,0xFFFF) BANK0(0x8000, ?CO?MYCODE) ...

If you use the µVision IDE, enter the following in the Misc Controls input box in the L51 Misc dialog box.

BANK0(?CO?MYCODE (0x8000))

This locates the code variables from MYCODE.C in BANK0.

MORE INFORMATION

  • Refer to BANKx in the BL51 User's Guide.

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  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.