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/MSP430F5528: sqrt Function causes my program to fail when firmware is uploaded in debug mode

Part Number: MSP430F5528


Tool/software: Code Composer Studio

I'm using an MSP430 in my device to take light measurements.  I take 20 measurements and store them in the array.  I wanted to calculate the standard deviation of the measurements, but I am having issues with the sqrt function.  I include math.h and sqrt is called in this function:

double standardDeviation (int average, int measurements[], int positions){ //KG 1/8/2017 Calculate the standard deviation of the data set

	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;

}

#include <math.h> is at the header of my .c file.

I am using CCS v5.5, compiler TIv4.1.9 with an output format of eabi.  The optimization level is set to 0.  When I comment out the line that includes sqrt, everything compiles and works as expected.  With sqrt included, debug mode is automatically running and when I try to pause it I get an error.  When I disconnect the debugger, the inputs and outputs of the device top working.

A few weird things are sqrt text is purple and when I look up the declaration, I have two options; from compiler 4.1.9 and one from 4.2.1