AnsweredAssumed Answered

Initialize const data to zero

Question asked by Ruben Valls Blasco on Jul 15, 2009
Latest reply on Sep 1, 2009 by Ruben Valls Blasco

Hi everyone! I'm having an isue with the initialization of constant data to zero:

 

I have got a section wich is mapped to ROM, and in this section there is only one constant variable initialized to zero. The problem is that this information is not written to the .bin file generated by the compiler so when I donwload it to the device, it is initialized to 0xFFFFFFFF (not initialized, just the memory erased).

The mapping and the .lcf is correct, because if I initialize this variable to 1, it appears in the .bin file, and when I debug, it is correctly initialized.

 

Any idea of what is happening?

 

I am using CodeWarrior V 6.4 and a Coldfire 52233 device.

 

.lcf:

----------------------------------------------------------------------------
    vectorrom  (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000800
    rom     (RX) : ORIGIN = 0x00000800, LENGTH = 0x0003F000
    persVars (RX) : ORIGIN = 0x0003F800, LENGTH = 0x00000800

 

                     . . .

 

    .persisteVariables:
    {
     ___DIR_RAM_PERSISTENT_VARS_START = .;
     *(persistVars)
     ___DIR_RAM_PERSISTENT_VARS_END = .;
     . = ALIGN (0x10);
    } > persVars

 

---------------------------------------------------------------

In ConstantVars.c:

 

#pragma define_section persistentVars "persistVars" far_absolute R
#pragma force_active on

__declspec(persistentVars) uint32 ROM_contrast_level=0; //Almacena el nivel de contraste del dispositivo (de 0 a 15)
//Mismas variables en RAM.
uint32 contrast_level;

#pragma force_active off

 

I tried with force_active, but it is not necessary because it is already in use (anyway, it appears in the map file) .

 

Why if I initialize it to 1 it appears in the .bin file, and in the debugger is correctly programmed and if I initialize to 0 it doesn't?

 

Thanks everyone for the help,

Rubén

Outcomes