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.

viewing float values in CCS5

Hi, I am working with a few functions from the math.h library but I am unable to see the results of the functions when i debug.  

The functions and variables compile and load, but in CCS while debugging I cannot see the variables in the variables tab and when i add them to the watch window they They appear to compile and load, but the variables that the type is unknown and the identifier is not found.  

What do i need to do to see the results of these functions. 

Here's the code. 


#include <msp430.h>
#include <math.h>

// *************************************************************************************************
// Prototypes section
void math_func(void);

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

math_func();
//float p = exp(0);
//float c = acos(0.5);

P1DIR |= 0x01; // Set P1.0 to output direction

for (;;)
{
volatile unsigned int i; // volatile to prevent optimization

P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR

i = 10000; // SW Delay
do i--;
while (i != 0);
}
}

#pragma CODE_SECTION(math_func, ".data")
void math_func(void)
{

float volt;

double p = exp(0);
double c = acos(0.5);
volt = (float) (512*0.0034799); // = 1.781733...
volt = volt * 1000;// => volt = 1781

}

  • You have to pause the program to see the values. Halt the program after the calculation and CCS will show the content of the variable. And turn optimizations off completely for debugging. Variables that are not used after calculation can get optimized away. Or you declare them volatile/global.
  • Thank you. I was stopping execution to view the variables, but it still did not show anything.

    I have not specifically set any optimizations, does the system do it automatically? What tab would I find this under (CCS 5.5)

    I will try making the variables volatile.

**Attention** This is a public forum