Discussion Forum

How to initial the value when using "_at_" locate instruction?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Mu qiyong
Posted
18-Feb-2007 03:31 GMT
Toolset
C51
New! How to initial the value when using "_at_" locate instruction?

This is correct code with absolute address locating:

#define USER_FLASH_SIZE 32
#define USER_FLASH_BASE_ADDR 07df
code unsigned char USER_FLASH_SPACE[USER_FLASH_SIZE] _at_ USER_FLASH_BASE_ADDR;


This is correct code with initializing:

#define USER_FLASH_SIZE 32
code unsigned char USER_FLASH_SPACE[USER_FLASH_SIZE]="Hello, this is my test string!";


This is what I want, but it failed:

#define USER_FLASH_SIZE 32
#define USER_FLASH_BASE_ADDR 07df
code unsigned char USER_FLASH_SPACE[USER_FLASH_SIZE]="Hello, this is my test string!" _at_ USER_FLASH_BASE_ADDR;


It shows this error message:
GLOBAL.C(4): error C141: syntax error near '_at_'

Please help me solve this problem: absolute locating and initialzing.

Read-Only
Author
Jonny Doin
Posted
18-Feb-2007 05:15 GMT
Toolset
C51
New! Use the linker locate commands

Assuming that you are linking with BL51:

To locate and initialize a variable, you must use the linker locate commands. The simplest way to do so is to declare your constant in a separate .c file that contains only the segment that needs to be located at absolute memory position. Then you use the BL51 Locate tab at the options dialog to assign an absolute position to the segment.

For example, you generate at a file named 'userdata.c':

// USERDATA.C
//
// Exampleware of absolute located initialized vars
//
// This segment will be named ?CO?USERDATA

unsigned char code user_flash_space[] = "supercalifragilisticexpialidocious";
unsigned char code foobar = 0x55;


Then you put in the Code: entry box the following string: ?CO?USERDATA(0x07DF)

The linker will allocate the absolute segment before all other code objects, at the address you specified.

Read-Only
Author
Jonny Doin
Posted
18-Feb-2007 05:19 GMT
Toolset
C51
New! BTW, That's in the MANUAL

Chapter 9 of the Assembler/Utilities manual, and Chapter 6 of the Cx51 Compiler Manual.

Read-Only
Author
Andy Neil
Posted
18-Feb-2007 07:05 GMT
Toolset
C51
New! RE: BTW, That's in the MANUAL

http://www.keil.com/support/man/docs/c51/c51_le_absvarloc.htm

and links to the knowledgebase:

http://www.keil.com/support/docs/937.htm

Next Thread | Thread List | Previous Thread Start a Thread | Settings