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/MSP430FR5994: Error in statically defined float array

Part Number: MSP430FR5994

Tool/software: Code Composer Studio

I know there is a recommendation to avoid floats - but we are porting some code as a POC ...

Can you help me understand why the following code produces incorrect results?

float testArray1[] = { 0.0, 1.0, 2.0, 1.22, 4.0, -1.802299, 6.0, 7.1234, 8.0, 9.0, 10.0, -11.9876, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 9999.0};

float *fvalue = (float *) 0x10000; // force "far" pointer to be created

void test()

...

for(i=0; i<NUMBER_TEST_ELEMENTS; i++)
{
uartA0IntValue(" [", i);
uartA0FloatValue("]:", testArray1[i]);
}

...

}

Produces the following:

[0]:0.0 [1]:1.0 [2]:2.0 [3]:1.22000 [4]:4.0     [5]:-1.32767     [6]:6.0 [7]:7.12340 [8]:8.0 [9]:9.0 [10]:10.0      [11]:-11.32767       [12]:12.0 [13]:13.0 [14]:14.0 [15]:15.0 [16]:16.0 [17]:17.0 [18]:18.0 [19]:19.0 [20]:20.0 [21]:21.0 [22]:22.0 [23]:23.0 [24]:24.0 [25]:9999.0

[5] should be:  -1.802299   BUT instead is -1.32767  

[11] should be:  -11.9876   BUT instead is: -11.32767

  • You haven't shown the code for uartA0FloatValue. How does it work?

    My debugger displays the array just fine. 

  • Hi Bruce,

    Apologies - the developer found the issues in the example : but the bigger question was the best/recommended way to load static data with the code to the device. Currently defining a +40K static array that contains the data. The developers will then have multiple data structures point to that block of data - based on offsets.

    Overtime, we would update this static data in an over-the air fashion,

    Any thoughts/suggestions would be much appreciated.

**Attention** This is a public forum