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/MSP430FR2433: Boot Hook Functions for System Pre-Initialization

Part Number: MSP430FR2433


Tool/software: TI C/C++ Compiler

Section 6.9.1, "Boot Hook Functions for System Pre-Initialization," of the MSP430 Optimizing C/C++ Compiler User's Guide (SLAU132R), says that we have three boot hook functions available to us. Listed are the three functions. I have some questions about them.

  • _system_pre_init()
  • _system_post_cinit()
  • _c_int00( )

When using the _system_post_cinit() function, does this function require a Return statement, and if so what are the values available to me? Also, are there any parameters, or should the parentheses contain void?

Can somebody provide me a code example for using the _c_int00( ) function? I just need something simple to understand the syntax. For example, like setting a bit in Field 0 of the Port 1 Direction Register (P1DIR |= BIT0;) for a GPIO module.

  • My copy of the CC User Guide (SLAU132S) Sec 6.9.1 says "_system_post_cinit(): [...]This function should not return a value." If you don't have any constructors, putting something here is probably not much different from putting it at the top of main.

    _system_pre_init has value if you have large globals that take so long to initialize that the WDT goes off. There have also been a couple of different people here recently who were using it for SRAM research.

    While section 6.9.1 mentions _c_int00, it doesn't cite it as a Boot Hook Function. This is the function (pointer) that is put into the reset vector. In practice, CCS chooses one of a few different "_c_int00"-s to use, depending on CCS options. Unless you're planning to craft your executable image by hand, you probably shouldn't mess with this. If you want to see the source, the simplest way is to do a "Hard Reset" in the debugger, which will take you right there.

  • Bruce:

    Why are you working during Saturday evening? You should be outside having a cocktail with friends and neighbors.

    You mostly, but not completely, confirmed how I was perceiving these three functions, especially about _c_int00. However, I want to make sure I've got this right.

    As for the _system_post_cinit() function, you don't think it returns any value. It's sounds like you are not one hundred percent sure about whether it returns a value or not. This might clarify the topic, or make it more complicated. Just now, I decided to look into the boot_hooks.h file, and it declares both init() functions as being void of returns and are both void of taking any parameters, but in reality,  _system_pre_init() does return a 0 or 1. What do you think? What's going on here?

    As for the _c_int00 function, I saw that the boot.c file appends that name in several different ways, depending on...well, I've read that file over and over again, I can't comprehend it. It appears to depend on something which is complicated. That all doesn't seem to matter anyways, since _c_int00 is something that we cannot use like the first two boot hook functions, and that its real purpose is act as vector. Section 6.9.1 should probably be rewritten to reflect that.

    -Thomas

    P.S. Do you know where the MAP file is located? I've forgotten.

  • "This function should not return a value." seems pretty clear to me.

    My copy of "tools\compiler\ti-cgt-msp430_18.1.5.LTS\lib\src\boot_hooks.h" says:

    > extern int  _system_pre_init(void);

    and

    > extern void _system_post_cinit(void);

    Since you've found boot.c you can see where _sytem_pre_init() is called, and how the return value works. I'm not sure what your question is.

    The .map file is put in the build directory (first guess: Debug).

  • Thanks for pointing out that the return type for _system_pre_init(void) is an integer. I over looked that. You've answered all my questions.

    Just as a reference to everybody, a code example of _system_pre_init(void) can be found in section 6.2, "Program Development," in the Code Composer Studio™ IDE v8.x for MSP430™ MCUs" (SLAU157). Here it is for those who might be interested.

    int _system_pre_init(void)
    {
    /* Insert your low-level initializations here */
    WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog timer
    /*==================================*/
    /* Choose if segment initialization */
    /* should be done or not. */
    /* Return: 0 to omit initialization */
    /* 1 to run initialization */
    /*==================================*/
    return (1);
    }