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.

Initialized Global Variables not getting reinitialized upon restart

Other Parts Discussed in Thread: MSP430F5326

This should be an easy one to fix for someone who understands code composer better than I do.

I have an initialized global variable:

int indx = 0;

However, I have noticed that when I terminate a debugging session, then start a new debugging session (i.e. click debug icon), this variable does not get reset to zero... Is this the expected behavior for code composer? I thought it was a part of the C standard to always reinitialize global variables that are declared initialized...

Thanks for everyone's help in advance!

  • Hi,
    I moved your thread to the CCS forum as you should be able to get better support here.
    Mike
  • Which device and board are you working with?

    A S said:
    then start a new debugging session (i.e. click debug icon), this variable does not get reset to zero

    Does your program run to main() before you check it's value? After the debugger starts, the processor needs to execute the boot initialization code in order for global variables to be initialized. At the end of the boot routine, is when main() is called.

    There is also a linker option which tells the build tools "not" to do the initialization. This is useful for some embedded systems, such as when one processor boot loads a second processor. This option is not usually on by default (in the processors I've worked with), but is something that might be checked out.

    Good Luck,
    Scott

  • When you say does my program "run to main() before I check its value", how do I check its value? When the debugger starts, the pointer starts in main()... I understand that a c_init() function occurs before, but I'm not sure how to access it.

    My Linker summary of flags set is:

    -vmspx --abi=eabi --data_model=large --code_model=large --near_data=globals -Ooff --use_hw_mpy=F5 --advice:power="all" -g --define=__MSP430F5326__ --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU23 --silicon_errata=CPU40 --printf_support=full -z -m"file.map" --heap_size=160 --stack_size=240 --cinit_hold_wdt=on -i"C:/ti/ccsv6/ccs_base/msp430/include" -i"C:/ti/ccsv6/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/include" --reread_libs --warn_sections --diag_wrap=off --display_error_number --xml_link_info="file_linkInfo.xml" --use_hw_mpy=F5 --rom_model

    I'm using --rom_model which should be ensure that the variables are reinitialized... I'm almost certain that no linker options telling the build tools not to do the initialization have been checked...