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.

CC430F6135 MSP-FET430UIF not running after increasing static array size

Other Parts Discussed in Thread: CC430F6135

Hello guys,

I'm using CC430F6135 microcontroller, whit ccs v5.3 and TI MSP-FET430UIF for debug. After I added a new static variable into my code, debugger stop starting. To test if the problem was adding the static variable, I tested this code in a new project:

#include <msp430.h>

#define ARRAY_SIZE 510
static unsigned int crash_array[ARRAY_SIZE];

/*
 * main.c
 */
int main(void) {
    unsigned int i;

    WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
    
    for (i=0;i<ARRAY_SIZE;i++)
        if (i>=1)
            crash_array[i] = crash_array[i-1];


    while(1);
}

If ARRAY_SIZE is 509 debugger run just fine. If ARRAY_SIZE is 510 debugger start acting strange. For example, for ARRAY_SIZE 509 version, after loading the code debugger current instruction pointer (the green highlighted line) points to the line " WDTCTL = WDTPW | WDTHOLD; ". For ARRAY_SIZE 510 version, after loading the code, there is no debugger current instruction pointer. If I pause program execution and view disassembly code, the program is always somewhere in C initialization program part.

I'm running out of ideas to solve this, so I could use some help over here.

Thank you.

  • Thank you very much Leo. Problem Solved.

    Here is the final working code for ccs.

    #include <msp430.h>

    #define ARRAY_SIZE 510
    static unsigned int crash_array[ARRAY_SIZE];

    int _system_pre_init(void)
    {
        return 0;
    }

    /*
     * main.c
     */
    int main(void) {
        unsigned int i;

        WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
        
        for (i=0;i<ARRAY_SIZE;i++)
            if (i>=1)
                crash_array[i] = crash_array[i-1];


        while(1);
    }

  • Better solution:

    #include <msp430.h>

    #define ARRAY_SIZE 510
    static unsigned int crash_array[ARRAY_SIZE];

    int _system_pre_init(void)
    {
        WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
    }

    /*
     * main.c
     */
    int main(void) {

    //Do actual work here...
        while(1);
    }
  • Hi Brian,

    Brian Boorman said:

    Better solution:

    #include <msp430.h>

    #define ARRAY_SIZE 510
    static unsigned int crash_array[ARRAY_SIZE];

    int _system_pre_init(void)
    {
        WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
    }

    /*
     * main.c
     */
    int main(void) {

    //Do actual work here...
        while(1);
    }

    [/quote]

    don't forget the "return 1;" at the end of _system_pre_init(). I did it once, and it gave me a headache why the program goes wrong.

    By the way i liked your way to post the code as "quotes" to make it more like a real code post. I am really missing this feature for posting code in E2E here.

  • Leo Hendrawan said:
    don't forget the "return 1;" at the end of _system_pre_init().

    Ah yes. Well I use IAR, which uses a different function name ( __low_level_init() ) to accomplish this feature. In IAR the return value specifies whether the C startup code initializes the variables or not.

**Attention** This is a public forum