TMS320F280049C: Sinf function issue

Part Number: TMS320F280049C

Hi team,

Here's an issue from the customer may need your help:

CCS version:10.3.1.00003/Kit used: V21.12.0.STS.

Use the sinf function in the CLA, and use RAMPGEN_run to generate the sin waveform. When verifying the waveform, the sin appears to be wrong. Place sin in the duty of pwm and observe it. The following figure shows the sin waveform with DAC and the duty updated to PWM, which drops one piece of the waveform suddenly, as shown in the figure, and the same behavior is observed with the duty of PWM: 

The following figure shows the angle information, the angle is normal, but PWM still has an abnormal duty: 

So it was determined that there was an sinf-related issue, the customer would like to know what should be noticed or taken into account when using the sinf function? 

Could you help check this case? Thanks.

Best Regards,

Cherry

  • Hi Cherry,

    1. The CLAmath library provides a optimized assembly function CLAsin  and a C code function CLAsin_inline. Which of these are being used on the CLA side to generate the sine wave?

    2. Is the sine wave being generated inside a background task by any chance?

    Thanks,

    Ashwini

  • Hi Ashwini,

    Thanks for your help.

    1. The CLAmath library provides a optimized assembly function CLAsin  and a C code function CLAsin_inline. Which of these are being used on the CLA side to generate the sine wave?

    #define sinf __relaxed_sinf

    __inline float __relaxed_sinf(float x)
    {
    return __sin(x);
    }

    2. Is the sine wave being generated inside a background task by any chance?

    Yes, it's generated inside the background task in CLA.

    Thanks and regards,

    Cherry

  • Hi Cherry,

    Could it be that the interruption of background task in between the processing could be causing this? Can the background task be changed to regular Task 8 to see if the same issue occurs?

    Thanks,

    Ashwini

  • Hi Ashwini,

    Using cla1 task does not have this problem.

    If it is a background task problem, does the program in it run the same issue? Is the CLA background task currently executing normally? Are there any limitations?

    Thanks and regards,

    Cherry

  • Hi Cherry,

    Could it be that a normal task is interrupting the background task and is causing this issue.

    You can try using intrinsics to disable task preemption and enable it again once critical code is executed.

    These intrinsics can be used to temporarily prevent such interrupts from suspending the background task.
    • __disable_interrupts();
    • __enable_interrupts();

    Thanks,

    Ashwini