Technical Support

C51: GLOBAL OR STATIC VARIABLES NOT BEING INITIALIZED


Information in this article applies to:

  • C51 All Versions

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 µVision 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

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Monday, May 10, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure