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.

Stuck doing memset before entering main

Other Parts Discussed in Thread: MSP430G2955

My target is based on MSP430G2955. I am using CCS 6.2.0.00050 with mspgcc. Compilation is optimized with -Os and -O1. I'm guessing that globals are being initialized by a call to memset even before calling main().

Problem is that target gets stuck inside memset. It's always within memset.


My friend who has the exact codebase has no issues when using TI compiler. He can do this because he has a full CCS license. I have only a code size limited version of CCS and hence I am using mspgcc.

  • Arvind Padmanabhan said:
    Problem is that target gets stuck inside memset. It's always within memset.

    It could be that time taken initialize the globals means the watchdog fires before main is reached.

    By default the TI compiler disables the watchdog during the global variable initialization, via the --cinit_hold_wdt option.

    For the GCC compiler you have to add code to disable the watchdog during global variable initialization - see CCSv6 / MSP430-FET430UIF Debugger no longer stops at start of program.

    [Note that the behavior of the GCC compiler has changed between versions as mentioned in the referenced thread, and you haven't said which version of mspgcc is in use]

  • Awesome. It solved my problem. Added this code as noted in the other reported issue:

    // disables the watchdog between the __start() and the __crt_0init()
    __attribute__ ((naked,section(".crt_0010init")))
    void __gcc_disable_watchdog() {
    WDTCTL = (WDTPW + WDTHOLD);
    }

    FYI, I am using gcc_msp430_5.3.0.219

**Attention** This is a public forum