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.

Compiler/AM3352: The variable got initialized before getting into Main()

Part Number: AM3352

Tool/software: TI C/C++ Compiler

Program before main() initializes structure DSP_Component.

I'm sure about the initializing value to DSP_Component here is not a random value.

Also, I searched DSP_Component in Memory Browser and found nothing.

The true values at 0x81C2510C seems not matching with value in Expressions window.

This variable is placed at named section .mass_data, but I'm not sure this is related with this problem or not.

I also set a hardware watchpoint on this variable, still found nothing.

How it comes? Thanks

  • I'm not sure what you are asking.  Is DSP_Component initialized with the correct values?  Does this initialization occur before main starts?  Do you want an explanation of how that works?

    Thanks and regards,

    -George

  • Sorry that I asked a question in a stupid way.

    As far as I know, variable DSP_Component should be initialized to 0, because it's a global variable.

    But now it's with a neat value(not random).

    I changed its value directly from within expression window and reloaded program again, and found that this changed value is unchanged.

    Then I went through DSECT and manual says:

    Global symbols defined in a dummy section are relocated normally. They appear in the output module's symbol table with the same value they would have if the DSECT had actually been loaded. These symbols can be referenced by other input sections

    Although I cannot understand it totally, this phenomenon partly makes sense.

  • Andy Lin94 said:
    As far as I know, variable DSP_Component should be initialized to 0, because it's a global variable.

    Correct.  This initialization to 0 does not happen when the device powers on.  Startup code, which executes before main, performs that task, among many others.  Whenever you somehow restart execution, you have to make sure the startup code executes.

    Regarding DSECT ... This is a rarely used feature of the linker.  It appears to be wrong to use it in your case.  Please read more about DSECT here.

    Thanks and regards,

    -George

  • Hi.
    The reason I asked "Q4: The Linker options "-e Entry" is not described by user guide." is that I want to check where is the startup code.
    I want to find out startup code and to make sure who handle this variable.
  • The startup code comes from the compiler RTS library.  The source code to the RTS library is part of the compiler installation.  If you have the compiler installed as part of Code Composer Studio, then a typical location is ...

    C:\ti\ccsv8\tools\compiler\ti-cgt-arm_18.12.0.LTS\lib\src

    The startup code is split among a few files.  Start with the files named boot_something

    Thanks and regards,

    -George