ARM Technical Support Knowledge Articles

IMPLEMENTING XDATA BANKING

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I know that code banking is built-in, but my question concerns XDATA banking. I have a 128K SRAM that is configured on the board as 4x32K ram areas. Is there any type of intrisic support for banked XDATA? if not, do you have any ideas for how (or if) I could build it in?

ANSWER

There is no built in support for XDATA banking, however, it is easy to implement this yourself. The best way is to use XBYTE to access XDATA as an "array".

Example 1: Accessing a 32k "array" in two XDATA banks:

// access XDATA in bank 0
P1.0 = 0;
XBYTE[0x36FF] = 4;

// access XDATA in bank 1
P1.0 = 1;
XBYTE[0x2143] = 6;

Example 2: Accessing 16M of RAM split over 256 XDATA banks:

void write_byte(unsigned long loc, unsigned char byte)
{
P1 = (loc >> 16) & 0x00FF;   // Write upper address byte
XBYTE[loc & 0x0000FFFF] = byte;   // Write data byte
}

unsigned char read_byte(unsigned long loc)
{
P1 = (loc >> 16) & 0x00FF;   // Write upper address byte
return (XBYTE[loc & 0x0000FFFF]);   // Read data byte
}

Note the use of P1 to select the XDATA bank. You may use fewer bits from the port if you don't need 16 MegaBytes of XDATA.

MORE INFORMATION

Article last edited on: 2005-07-15 13:15:47

Rate this article

[Bad]
|
|
[Good]
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