Keil Logo

C51: LOCATING VARIABLES IN MULTIPLE XDATA AREAS


Information in this article applies to:

  • C51 Version 6.01

QUESTION

My 8051 target hardware does not have continuous XDATA memory. Is there a way I can declare the XDATA that is available for variables so that the compiler and linker automatically locate my XDATA variables automatically?

ANSWER

Yes. In C51 V6.01 and later, you may specify XDATA ranges to the BL51 linker. You may specify a range for each valid XDATA area and let the BL51 linker locate your XDATA segments automatically.

For example, suppose you have XDATA ranges from 0x0000 to 0x1FFF and from 0x4000 to 0x4FFF. And, that you have segments (?XD?SEG1, ?XD?SEG2, and ?XD?SEG3) which should be located in the XDATA range from 0x0000-0x1FFF and the following segments (?XD?SEG4, ?XD?SEG5, and ?XD?SEG6) which should be located in the XDATA range from 0x4000 to 0x4FFF.

On the Command Line

Compile as normal. Use the following linker command line:

BL51 ... XDATA (0x0000-0x1FFF,0x4000-0x4FFF,
         ?XD?SEG1 (0x0000), ?XD?SEG2, ?XD?SEG3, ?XD?SEG4 (0x4000), ?XD?SEG5, ?XD?SEG6)
  • XDATA (0x0000-0x1FFF,0x4000-0x4FFF, specifies the XDATA ranges to the linker.
  • ?XD?SEG1 (0x0000), ?XD?SEG2, ?XD?SEG3, specifies that ?XD?SEG1 should be located starting at 0x0000. All subsequent XDATA segments (?XD?SEG2 and ?XD?SEG3) are located (in order) immediately after ?XD?SEG1.
  • ?XD?SEG4 (0x4000), ?XD?SEG5, ?XD?SEG6) specifies that ?XD?SEG4 should be located at 0x4000. All subsequent XDATA segments (?XD?SEG5 and ?XD?SEG6) are located (in order) immediately after ?XD?SEG4.
  • All remaining XDATA segments are located after ?XD?SEG6

Since all unspecified XDATA segments are located after the last specified XDATA segment, you may avoid listing ALL XDATA segments in the linker command line.

In µVision2

  1. Specify the XDATA ranges on the Target Off-chip XDATA Memory dialog.
  2. Add the following to XDATA Segments on the BL51 Locate dialog: ?xd?seg1 (0x0000), ?xd?seg2, ?xd?seg3, ?xd?seg4 (0x4000), ?xd?seg5, ?xd?seg6

SEE ALSO

FORUM THREADS

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

Last Reviewed: Saturday, July 9, 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.