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.

TMS320F280025C: Why the C standard trigonometric function "sin()" is taking 5 secs for execution?

Part Number: TMS320F280025C

Hello!

When I "Step Over"  the instruction y=sin(x) in CCS debug mode, it takes around 5 secs for the CCS to update the value of variable y. Does the MCU really take such long time to execute such trigonometric functions?

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);

  • If you build with the newer EABI, and not the older COFF ABI, then this ...

    y=sin(x);

    ... is the same as ...

    Fullscreen
    1
    y = (float32_t) sin((double)x);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    x is converted to a 64-bit double; the sin computation is performed with 64-bit wide double operations; the result is converted to 32-bit float before assigning to y.  Perhaps worst of all, none of this uses the 32-bit floating point instructions available on this device.  

    Consider calling sinf instead. Then there are no conversions, and the computation is done with 32-bit floating point instructions.  

    If you want the compiler to warn you when you make this particular mistake, add the build option --float_operations_allowed=32.  Please search for it in the C28x compiler manual.

    Please let me know if these suggestions resolve the problem.

    Thanks and regards,

    -George

  • Thank you very much George for your reply!

    Using sinf instead reduces the time to 3 secs. And when --fp_mode=relaxed is set then it just executes at approximately the same rate as other instructions do. Does --fp_mode=relaxed mean that FPU is not used? And what is the significance of TMU if trigonometric functions take too much time to execute?

    Regards,

    Duman

  • Using both the options --fp_mode=relaxed and --tmu_support means TMU instructions get used for certain operations, including atan2.  If this does not happen, then for that source file, please follow the directions in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George