ARM Technical Support Knowledge Articles

AVOIDING STARTUP INITIALIZATION OF STATIC VARIABLES

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I have a C function which contains some xdata static variables. When the device is reset I do not want the locations those variables are stored at to be initialized to 00H by the startup code. How can that be achieved?

ANSWER

The file STARTUP.A51 includes the code for initialization of data memory and is included with every project if required. By default the XDATA is not initialized however the STARTUP.A51 file allows this to be easily configured.

The easiest way to avoid initialization of static or global variables is by performing the following steps:

  1. Absolutely locate the variables at particular locations e.g:
    xdata static unsigned int foo _at_ 0xF3C1;
    
  2. Copy the STARTUP.A51 file to your project.
  3. Edit the STARTUP.A51 file so that the static variable locations are not initialized.

If you include all your static variables in a single structure then you can absolutely locate that structure rather than every single variable.

Note that you need to copy INIT.A51 to your project directory and modify it if you want to remove initialization of all global variables.

MORE INFORMATION

SEE ALSO

Article last edited on: 2006-10-24 13:43:36

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