ARM Technical Support Knowledge Articles


Applies to: C51 C Compiler


Information in this article applies to:


My application requires large amounts of RAM which is available on my hardware. But, I need to access it through the Compiler and Linker.

I have an ASIC containing an 8051 core that supports XDATA banking with 32 kbyte pages at X:0x8000-X:0xFFFF. An SFR named XPAGE at address D:0x95 is used to select the XDATA page. So, the memory map appears as follows:

X:0x0000 - X:0x7FFF    Common Xdata Memory
X:0x8000 - X:0xFFFF    Page 0 Xdata
X:0x8000 - X:0xFFFF    Page 1 Xdata (Selection via SFR at D:0x95)

How can I configure the C51 Compiler and the extended LX51 Linker/Locater to use this paging mechanism?

How can I allocate variables in the various xdata memory pages?

Can I allocate large arrays (of 64K size) in the C code?


Large memory and XDATA banking are supported starting with Version 6.20 of the PK51 Professional Developer's Kit (C51 Version 6.20). In this and later releases, the memory types far and far const allow you to place variables in banked RAM (far = HDATA) and ROM (far const = HCONST). Since your memory is fragmented into 32 KByte blocks, it is not possible to create arrays larger than 32 KBytes.

The XDATA banking is configured using the XBANKING.A51 file found in the KEILC51LIB folder. To configure the tools for your application:

  1. Copy KEILC51LIBXBANKING.A51 to your project folder and add it to your project. You must configure the ?C?XPAGE1SFR and ?C?XPAGE1RST values in this file. For your hardware, ?C?XPAGE1SFR must be 0x95 and ?C?XPAGE1RST should contain the reset value for this SFR that is required to address page 0 of your XDATA RAM.
  2. Variable Banking requires that you use the LX51 Extended Linker/Locater (which is only included with the PK51 kit). The LX51 Linker/Locater is enabled under Project - Select Device for Target - Use Extended Linker (LX51).
  3. Under Project - Options for Target - Target you must enable far memory type support. If you access far variables in interrupt functions you must also enable Save address extension SFR in interrupts. You may specify the size for the standard unbanked xdata memory in this dialog under Off-chip xdata memory (RAM #1 Start: 0 Size: 0x8000).
  4. The address regions of the memory banks are specified under Project - Options for Target - LX51 Locate - User classes. Since you are banking only the upper 32KB of the xdata memory, you must specify: HDATA (X:0x8000-X:0xFFFF, X:0x18000-X:0x18FFF, X:0x28000-X:0x2FFFF, X:0x38000-X:0x3FFFF).

This configuration for the Compiler and Linker will allow you to use the extended memory regions of your hardware.

To allocate variables in these spaces, simply declare them as far memory types. For example:

int far array [100];


Article last edited on: 2006-10-24 14:07:36

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential