This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Initializing global variable



Hi,  everyone

          I used CCS4.5 to develop OMAP137 ARM.  I want to initialize global variable when they are defined,  for example,  "int   aa= 123;" (before main and other functions)   and the compiler hasn't report any error, but when I ran the program,  the variable ' a '  isn't   123.   In the 'Build Options',  I chose  the "load- time initialization" item.  Is there something else I need to do ?

  • At what point are you checking the value of the global variable? Is should be done after you enter the main.

    Also please check if the .cinit and .bss sections are properly placed in the memory.

    Thanks,
    Gaurav

  • Gaurav,

          I checked the value during the program emulation,  steping  into  the main,   the global variable changed into other meanless value. Of course if I initialize it in the main function,  it will be correct.  But I need to initialize it out of the function, it means that the value of the global variable  need to be set during compilation.

          The .cinit and .bss sections are configured as below:

           SDRAM               :  o = 0xC0000400    l = 0x00800000    

          .bss        >       SDRAM
          .cinit      >       SDRAM

     

          Thank you,

          Daisy Wu

  • Is SDRAM properly initialized? Can you try placing these sections in internal memory?

    If this doesn't work, please provide us the code snippet for review.

    Thanks,
    Gaurav

  • Gaurav,

          I found that my compiler settings aren't proper,  and I have  corrected it. Thank you all the same

         

          daisy