ARM Technical Support Knowledge Articles

INITIALIZING & LOCATING A VARIABLE TO A FIXED ADDRESS

Applies to: BL51 Code-banking Linker/Locator

Answer


Information in this article applies to:


QUESTION

Can I direct my initialized constant string to a specific location? I tried using the _at_ keyword in C51, but I can't initialize this variable and locate it at a fixed address.

ANSWER

Yes. To initialize and locate a constant string, place the string in a file by itself. Then, use the linker to locate it at the address you want.

For example: create the following file called TAB1.C:

unsigned char code tab1 [] = { 1, 2, 3, 4, 5, 0 };

When you compile this file, the compiler creates a segment named ?CO?TAB1. This indicates that the data is stored in the code area and the source file is named TAB1.

On the linker command line, specify

BL51 ... CODE(?CO?TAB1(08000h)) ...

to locate this array at address 8000h.

In uVision...

This also locates the table at 8000h.

Refer to the 8051 Utilities User's Guide for more information.

Note that this will work for variables located in XDATA, DATA, and IDATA as well as those located in the CODE area.

MORE INFORMATION

SEE ALSO

Article last edited on: 2007-03-27 10:44:53

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