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.

CCS/MSP430FR6047: Code Compose not executing properly

Part Number: MSP430FR6047

Tool/software: Code Composer Studio

I have had many problems with the Code Composer not executing code properly. 

1. A subroutine  that returns an int fails on the second of two consecutive calls. There is a breakpoint in the subroutine where the return value can be inspected. It has a good value on both calls, say 100 and 200. The first call returns 100. The second call doesn't return the 200. In the example below, val1 is assigned 100 and val2 is assigned 0; I overcame this problem by making val1 and val2 global and testing the parameter ii to determine which variable to assign the return value to. The subroutine was changed to return void. 

,,,

int val1 = S1(1);

int val2 = S1(2);

...

int  S1(int ii) {

...

(breakpoint) return retVal;

}

2. Subroutines and loops exit without completing. I have had many examples and have been able to overcome most of the as I did in the example above. I cannot overcome the problem in the following case. I am trying to make a delay of one minute. The idea is to execute the following repeatedly to delay a minute.

void PST_Delay() {

Some kind of looping 

   int ii;

    for (ii = 0; ii < 1000; ii++) { //this should delay 1 second

        __delay_cycles(16000 -1); // This should delay 1 millisecond. 

    }

}

I have tire putting it in nested loops, in subroutines with loops, in subroutines with a global counter that is decremented. I have put in dummy code with breakpoints at various places and found that they are never reached, The routine always returns a a couple of seconds. Not only does it return without completing the loops, global variable that do not appear anywhere in the code have been zeroed. If I step through the code it works for as long as I keep stepping, say 20 times through the loops. Once run is clicked or pressed, the routine exits and some global variables are zeroed.

I have changed the optimization from level 3 to off. It made no difference.

What do you suggest?

Thanks

  • For now, let's focus on just this one problem ...

    Marty Diamond said:

    I am trying to make a delay of one minute. The idea is to execute the following repeatedly to delay a minute.

    void PST_Delay() {

    Some kind of looping 

       int ii;

        for (ii = 0; ii < 1000; ii++) { //this should delay 1 second

            __delay_cycles(16000 -1); // This should delay 1 millisecond. 

        }

    }

    For the source file which contains this function, please follow the directions in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George

  • You can easily reproduce the problem by adding the following subroutine and a call to it to the water flow demo software.

    _______________________________________________________________________________________________

    void PST_Delay() {

       int ii, jj;

       for (jj = 0; jj < 60; jj++) {

            for (ii = 0; ii < 1000; ii++) { //this should delay 1 second

                 __delay_cycles(16000 -1); // This should delay 1 millisecond. 

            }

        }

    }

    _______________________________________________________________________________________

    If you add the following to the jj loop and reduce the ii < 1000 to ii < 100 the problem goes await.

     hal_system_WatchdogFeed();

  • Hi Marty,

    Has the problem you described been solved? Do you still need our support?

    Best Regards

    Johnson

  • The problem has been solved in the sense that I worked around the problem.

    It is likely that with a better understanding I would understand why the wathcdog I added is necessary. I do think that you should be aware of the behavior and be able to help someone else that runs into it.

    Even though I figured out for myself how to get around the problem, I appreciate your response to the questions both on this an others I have sent in.