您好!
当我在 CCS 调试模式下"步越"指令 y=sin (x)时、CCS 更新变量 y 的值大约需要5秒。MCU 执行此类三角函数真的需要这么长时间吗?
Note: I measured the time with hand stop watch.
Relevant code lines are given below
#include <math.h>
float32_t x=10; float32_t y=0; y=sin(x);
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 调试模式下"步越"指令 y=sin (x)时、CCS 更新变量 y 的值大约需要5秒。MCU 执行此类三角函数真的需要这么长时间吗?
Note: I measured the time with hand stop watch.
Relevant code lines are given below
#include <math.h>
float32_t x=10; float32_t y=0; y=sin(x);
如果使用较新的 EABI 而不是较旧的 COFF ABI 进行编译,则...
[引用 userid="483831" URL"~/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1036133/tms320f280025c-why-the-c-standard-trigonometric-function-sin-is-taking-5-secs-for-execution ]y=sin (x);(笑声) 与...相同
y = (float32_t) sin((double)x);
x 被转换为64位双精度型;sin 计算是使用64位宽双精度运算执行的;结果在分配给 y 之前被转换为32位浮点型。 最糟糕的是、这一点都不使用此器件上提供的32位浮点指令。
请考虑调用 sinf。 然后没有转换、计算是通过32位浮点指令完成的。
如果您希望编译器在发生此特定错误时向您发出警告、请添加构建选项 -float_operations_allowed=32。 请在 C28x 编译器手册中搜索它。
请告诉我这些建议是否能解决问题。
谢谢、此致、
乔治
同时使用--fp_mode=relaxed 和--tmu_support 两个选项意味着 TMU 指令会用于特定操作,包括 atan2。 如果未发生这种情况、则 对于该源文件、请按照文章 如何提交编译器测试用例中的说明进行操作。
谢谢、此致、
乔治