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:浮点、产生不正确的结果

Guru**** 2380860 points
Other Parts Discussed in Thread: AM2632
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1517076/am2632-q1-floating-point-producing-incorrect-results

器件型号:AM2632-Q1
Thread 中讨论的其他器件:AM2632

工具/软件:

在 AM2632上使用浮点时会出现随机问题。  编译器选项设置如下(我删除了我们的大多数-i 选项)

-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 /ti/mcu_plus_sdk_am263x_10_01_00_31/source/drivers /ti/mcu_plus_sdk_am263x_10_01_00_31/source/kernel/freertos/config/am263x/r5f -i"C:-i"C:-i"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F /projects/slate/firmware/AX-BMSC-Debug/syscfg -i"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/drivers/uart/v0 -i"WDSC/am263x"-i"C:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/kernel/dpl -wall-then"-wall-thenge -debug:soc:/ti/mcu_plus_sdk_am263x_10_01_00_31/source/kernel/freertos/FreeRTOS-Kernel/include -not-w-w-debug -not"-wl-w-w-w-w-debug -not"/ti/mcu_plus_sdk_am263x_10_01_00_31/source -w-w-w-w-debug -w-w-w-w-w-w-debug

我们将使用 Code Composer 和 C:/ti/ccs1281/ccs/tools/compiler/ti-cgt-armllvm_4.0.1.LTS/bin/tiarmclang.exe 进行构建

下面是一些有问题的代码:

                   uint32_t uiVoltage;

                   双  fVoltage;

                   uiVoltage = 3500;
                   
                   fVoltage =(双) uiVoltage *(双) 100;
                   fVoltage = fVoltage /(双精度) 1000;

由于最后一行上计算出的 fVoltage 不正确、因此该误差随机发生。  我唯一能想到的是浮点寄存器不会在中断之间保留、从而破坏随机计算。  我无法在编译器选项或 syscfg 中找到相关的任何设置。  有什么我遗漏的吗?  我们使用的是 FreeRTOS、这是 FreeRTOS 配置项吗?  这一个让我完全窒息。

我已在调试器中检测到错误并查看了 uiVoltage 的值、该错误是正确的、但产生的 fVoltage 不是。

感谢您的见解。
      

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    我已提请编译器专家注意此主题以进行进一步分析。

    谢谢

    Ki

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    magic freeRTOS 调用   porttask_uss_floated_point(); 似乎已经解决了这个问题......