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/MSP430F2274: `_system_pre_init` jumps to `CSTART_DECL _c_int00_noargs` and never returns to the program

Part Number: MSP430F2274

Tool/software: TI C/C++ Compiler

When making simple test programs (mainly trying to get printf() to work), the program gets stuck in a loop and never returns, the code from boot.c is provided below, the parts of the code that are not hit are commented out. Is there a reason why it never moves to the second `if` statement following the line `if(_system_pre_init() != 0)`? In my main.c program there is a `_system_pre_init` function which stops the watchdog timer and returns 1, but that value is never passed to the `if` statement. Any workarounds or reasons why this occurs?

 if(_system_pre_init() != 0)
   {
      if (NEEDS_INIT)
         _auto_init();
   }

   /*------------------------------------------------------------------------*/
   /* Handle any argc/argv arguments if supported by an MSP430 loader.       */
   /*------------------------------------------------------------------------*/
//   if (NEEDS_ARGS)
//      _args_main();
//   else
//      main(0);

//   exit(1);
}

//CSTART_DECL _c_int00(void)
//{
//   _c_int00_template(1, 1, 0);
//}

CSTART_DECL _c_int00_noargs(void)
{
   _c_int00_template(0, 1, 0);
}

//CSTART_DECL _c_int00_noinit(void)
//{
//   _c_int00_template(1, 0, 0);
//}

  • This startup code has worked the same way for years.  It is unlikely to be the root cause of the problem.

    This sounds more like an error in the system configuration.  If that is the case, we compiler experts are not much help.

    Sean Kramer said:
    When making simple test programs (mainly trying to get printf() to work), the program gets stuck in a loop and never returns

    Does the program get to main?  Or does it get stuck before then?

    Thanks and regards,

    -George

  • #include <stdio.h>
    #include "msp430.h" int _system_pre_init(void) { WDTCTL = WDTPW + WDTHOLD; return 1; } int main(void) { _system_pre_init(); printf("testing...\n"); return 0; }

    It starts at main(), and then within main calls `_system_pre_init()`, it gets trapped in a loop within the boot.c file (which I did not create, it it is part of the msp430). My code is provided

  • Do not call _system_pre_init from within main.  The startup code calls the implementation of _system_pre_init which you supply.  

    All that said, this mistake should not cause a loop to occur.  I still don't understand how that happens.

    Thanks and regards,

    -George

  • Did you make this change?

    George Mock said:
    Do not call _system_pre_init from within main.

    Is it working now?

    Thanks and regards,

    -George

  • Since it has been a while, I presume you have resolved the problem.  I'd appreciate hearing how you resolved it.

    Thanks and regards,

    -George

  • No, the problem was never solved, and instead of wasting time trying to figure it out, I moved onto a different task since having printf is not necessary to have for this application (but it would make debugging much easier)