I am using Code Composer Studio to work with an MSP430 MCU. These are the specs that I am working with:
CCS version: 5.5
Compiler version: TI v4.1.9
Compiler Optimization Settings: Optimization = 0
MSP430: MSP430F5528
I'm starting with a working device and adding a new function to calculate the standard deviation of an array of measurements. The device has been working completely fine until I added the sqrt function in the below code:
double standardDeviation (int average, int measurements[], int positions){
double deviation = 0;
int i = 0;
for(i = 0; i <= positions; i++){
measurements[i] = measurements[i] - average;
measurements[i] = measurements[i] * measurements[i];
deviation += measurements[i];
}
deviation = deviation/positions;
deviation = sqrt(deviation);
return deviation;
}
Also, I have #include <math.h>
at the header of my file.
When I comment out the line with sqrt, the device works as expected. The Inputs and outputs and array values are all working perfectly. The signalling LEDs are as they should be and I can see the array values while in debug mode are as they should be.
With the sqrt line included, firmware that is being debugged automatically starts running. When I pause the program, I get this error:
"Can't find a source file at "/tmp/TI_MKLIBSF5oIb/SRC/copy_decompress_rle.c" Locate the file or edit the source lookup path to include its location."
With sqrt included, the device no longer functions as expected, even with deviation variable completely disassociated from any input or output of the device. After the firmware is uploaded on different occasions, the device has had all of the outputs turn on at once, none of the outputs turn on, and outputs randomly coming on and off. I cannot measure any values of the inputs because I can't pause the program.
Things I have tested:
- Commenting out measurements[]*measurements[] to make sure the value does not get too large, same failure described above
- Commenting out the line with sqrt, the device worked as expected
- Replaced the variable inside the sqrt function with 4, same failure described above
- Set all of the positions of the measurements[] array equal to 1, same failure described above
- Defined variable deviation in header to use static memory instead of dynmaic