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/TMS320F28075: Calculation error when use sincos() function

Part Number: TMS320F28075

Tool/software: Code Composer Studio

Hi,

I want to use the fastRTS Library and have installed it following the instructions. The code is simple, as shown below:

#include "F28x_Project.h" // Device Headerfile and Examples Include File
#include "C28x_FPU_FastRTS.h"
#include "math.h"

float theta, sin_theta, sin_theta_1, cos_theta, cos_theta_1;

void main(void)
{
theta = 0.0143617708;

sincos(theta, &sin_theta, &cos_theta);
sin_theta_1 = sinf(theta);
cos_theta_1 = cosf(theta);

while(1){}
}

But the sin_theta and cos_theta are not right derived from sincos() function. (compared with sinf() and cosf() results)

Following is my CMD file and settings related with fastRTS library.

The attached file is my project file. Could you please help me to find out what is wrong? Thank you in advance!

28075_TEST_fastRTS.zip

  • Hi Weijing,

    I've just go through the user guide of C28x Floating Point Unit fastRTS Library, I don't find sinf or cosf function in this lib. Can you please use the latest lib in cotrolsuite?

    I think the sin or sincos function could meet your requirement.

    - sin Single-Precision Floating-Point SIN (radians)
    Description Returns the sine of a floating-point argument X (in radians) using table
    look-up and Taylor series expansion between the look-up table entries.
    Header File #include <math.h>
    Declaration float32 sin (float32 X)

    - sincos Single-Precision Floating-Point SIN and Cosine (radians)
    Description Returns both the sine and cosine of a floating-point argument X (in
    radians) using table look-up and Taylor series expansion between the
    look-up table entries.
    Header File #include “C28x_FPU_FastRTS.h”
    Declaration void sincos(float32 X, float32* PtrSin,
    float32* PtrCos);
    X Input argument in radians
    PtrSin Pointer to the sine result
    PtrCos Pointer to the cosine result

    Regards,
    Jack
  • This thread may helps you. e2e.ti.com/.../625383

    Regards,
    Jack
  • Thank you for your reply!

    the sinf() and cosf() is in math.h. Here I just use these functions to do the comparison.

    I checked the fastRTS instruction, for 2833x, the FPUTABLES is located in the Boot ROM. But in 28075 cmd file, there is no such section, and I added it by myself. I guess, the section can be added, but there is no table in it. Maybe this is the reason why my sincos() function does not work right. Do you know any method to use the fastRTS library in 28075? How can I load the table to my MCU?
  • Oh wow..

    F28075 has TMU and you do not need fast RTS for the sin and cos function, and other functions that are supported in TMU. Therefore we do not add FPUTables in the CMD file. Using TMU is the fastest way to do trig operations on C2000 MCU.

    Enable TMU and use optimization and select floating point as relaxes and the TMU will kick in automatically, or alternatively you can use intrinsics

    www.ti.com/.../spru514n.pdf

    www.ti.com/.../spry288a.pdf


    Regards
    Manish
  • Thank you for your reply!