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 不是。
感谢您的见解。