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