Keil Logo

C51: CONFIGURING XDATA BANKING


Information in this article applies to:

  • C51 Version 6.20

QUESTION

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?

ANSWER

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 \KEIL\C51\LIB\ folder. To configure the tools for your application:

  1. Copy \KEIL\C51\LIB\XBANKING.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];

MORE INFORMATION

FORUM THREADS

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

Last Reviewed: Tuesday, May 5, 2015


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.