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.

AM2632-Q1: Floating Point Producing incorrect results

Part Number: AM2632-Q1
Other Parts Discussed in Thread: AM2632

Tool/software:

We are having random issues using floating point on the AM2632.  The compiler options are set as follows (I removed most of our -I options)

-mcpu=cortex-r5 -mfloat-abi=hard -mfpu=vfpv3-d16 -mlittle-endian -mthumb -I"C:/ti/ccs1281/ccs/tools/compiler/ti-cgt-armllvm_4.0.1.LTS/include/c" -I"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source" -I"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/drivers/uart/v0" -I"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/drivers/soc/am263x" -I"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/kernel/freertos/FreeRTOS-Kernel/include" -I"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F" -I"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/kernel/freertos/config/am263x/r5f" -I"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/kernel/dpl"  -DSOC_AM263X -D_DEBUG_=1  -g -Wall -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -I"C:/projects/slate/firmware/AX-BMSC-Debug/syscfg"

We are building using Code Composer and C:/ti/ccs1281/ccs/tools/compiler/ti-cgt-armllvm_4.0.1.LTS/bin/tiarmclang.exe

Some code in question is below:

                    uint32_t uiVoltage;

                    double   fVoltage;

                    uiVoltage = 3500;
                   
                    fVoltage = (double)uiVoltage * (double)100;
                    fVoltage = fVoltage / (double)1000;

The error occurs randomly in that the computed fVoltage on the last line is incorrect.  The only thing I can think of is that floating point registers are not being preserved across interrupts and thus corrupting random calculations.  I can not find any settings for this in the compiler options, nor syscfg.  Are there any that I am missing?  We are using FreeRTOS- is it a FreeRTOS configuration item?  This one has me totally stumped.

I have detected the error in the debugger and looked at the value for uiVoltage and it is correct, yet the resultant fVoltage is not.

Thanks for any insight.