ARM Technical Support Knowledge Articles

GLOBAL OR STATIC VARIABLES NOT BEING INITIALIZED

Applies to: C51 C Compiler

Answer


Information in this article applies to:


SYMPTOMS

I have some static and global variables which I am initializing when I declare them. When I run my program the variables are not initialized.

On stepping through the startup code it appears that the first byte of ?C_INITSEG - where all the initial values are stored - is set to 00H and this causes the initialization code to terminate prematurely.

CAUSE

The module INIT.A51 contains the initialization table terminator (=0). If this module is explicitly linked to an application, it must be the last module included in the linkage so that the terminator is located at the end of the initialization table. Usually, the linker takes the INIT module out of the libraries and automatically locates it at the right position.

Some customers have reported this problem when using Microsoft Make. By converting their project to use uVision the problem was resolved. It appears that in the process of converting the project, the INIT.A51 file was excluded (and was automatically included from the library) or was placed at the end of the file list.

RESOLUTION

Include the module INIT.A51 in your project only if you have modified it. If you need it, drag it to the very bottom of the µVision project window. If you use a linker command file, specify the INIT.OBJ file as the last module.

SEE ALSO

Article last edited on: 2004-05-10 15:43:11

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