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.

TMS320F28335: Fast Execution of Trignometric Function.

Part Number: TMS320F28335
Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE,

Hi,

I am working on a program having more than 70 trigonometric functions (Sine, Cosine mostly).

I am trying to run the program at 50 microseconds ISR.

I checked the execution time of IQSine, IQSinPU, sin are 530 ns, 460 ns and 460 ns respectively.

Execution of trigonometric functions taking much time in my program, 70-80% of my ISR time.

I am already using ramfuncs for faster execution.

Is there any way to increase the execution speed of trigonometric functions.

  • Sumanth,

    The FPUFastRTS library trigonometric functions benchmark sin, cos etc. at around 40 cycles. IQMath lib trig functions also take similar cycles. If you clock the CPU at 150MHz (6.67ns per cycle), that means, these take about 250ns. Your numbers suggest you are clocking the device lower than 150MHz.

    If your device had a TMU, then trig. functions would execute about times faster i.e. about 4 cycles per operation.

    Those are your two options, clock higher (of course there may be other system level constraints), or migrate to a device with a TMU.

    Thanks,

    Sira

  • Sira,

    Thanks for the reply.

    I cannot go to device having TMU, i will be using 28335 only.

    I am using 30MHz clock, and set PLL to 0x0A so it will run at 150 Mhz.

    I have included FPUFastRTS.

    Above picture indicates i am using BOOT ROM.

    Above picture indicates for sin and cos i am using fast supplement function. so Link order is correct.

    I am using input and output variables of sin function in different section of RAM than ISR RAM in which i am using sin function.

    Still i am getting timing of 460ns, please see the below figure.

    Thanks & Regards,

    Sumanth.

  • Sumanth,

    I think you should use sinf() instead of sin() for single-precision floating-point. sin() is a double-precision routine.

    Thanks,

    Sira

  • Sira,

    According to controlSUITE_C28x_FPU_FastRTS.pdf , sin is a single precision floating point.


    I didn't find the sinf() function in IQMathlib.h or math.h. 

    Can we decrease the time by solving sin & cos in assembly language ?


    Thanks,

    Sumanth.

  • Sumanth,

    Please migrate to the corresponding library in C2000Ware. We don't actively support ControlSUITE.

    If your output format is COFF, float and double are the same sign, so sin() and sinf() are identical. If it is EABI, then float is 32-bit whereas double is 64-bit, and sinf() is the single-precision call and sin() is the double-precision call.

    Please measure the cycle count using Code Composer Studio's clock feature (while debugging, select Run-Clock-Enable, and it will show up at the bottom right corner of the CCS window. Double click on it to reset it to 0. You can set breakpoints and measure the cycle count in this manner.

    So to summarize:

    1. Please move to C2000Ware FPUFastRTS library

    2. Check whether your output format is COFF. If it is, sin() is OK. If it is EABI, sinf() needs to be used.

    3. Measure the clock count using CCS clock.

    Thanks,

    Sira

  • Also, let me know your CCS version and Compiler version, and the optimization settings of your project. These should not matter too much since we are making a call into a hand-optimized assembly library, but I would prefer that you use a relatively new CCS version (v9 or later), TI Compiler v18.12.4.LTS or later, and optimization level -o2. To set breakpoints, if you need to lower the optimization level, go ahead and do so.

  • Sira,

    CCS Version: 6.2

    Compiler: 6.2.5

    Optimization setting: o2.

    Below are the observation:

    With RTSf32 Standard library as priority

    Flash: 6 + 128 cycles: 816nsec (observed from Oscilloscope)

    RAM: 3 + 125 cycles: 760nsex (observed from Oscilloscope)

    With FastRTS Supplement as priority

    Flash: 6 + 66 cycles: 508nsec(observed from Oscilloscope)

    RAM: 3 + 63 cycles: 456nsec(observed from Oscilloscope)

    Note: Both the libraries are controlsuite. Will update the observations with C2000ware library and Lastest CCS.

  • Sira,

    I installed CCS10.0.0, C2000ware & using compiler v20.2.0 LTS.

    optimization is 2.

    I copied the same project from CCS6.2 to CCS10.0.0. Then i changed the lib files from controlsuit to C2000ware.

    Below are the setting:

    Still my sin function is associated with fpu32 lib only. refer the below picture..

    Below is the warning:

    warning #10211-D: cannot resolve archive D:/WORK/Active Harmonic Filter -AHF/Firmware/AHF_CCS_10/AHF_ISR_PWM/libs/math/FPUfastRTS/c28/lib/rts2800_fpu32_fast_supplement.lib to a compatible library, as no input files have been encountered

    I checked with the COFF library too.

    Refer the below pictures:

    below is the picture from .map file.

    Below is the flash cmd file for reference.

    Below is the error shown:

    "../F28335_FLASH.cmd", line 169: error #10099-D: program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. placement with alignment/blocking fails for section "FPUmathTables" size 0x75cpage 0. Available memory ranges:
    FPUTABLES size: 0x6a0 unused: 0x6a0 max hole: 0x6a0

    I am using controller TMS320F28335. 

    Please try from your side to integrate the fast supplement file in f28335 program.

    Regards,

    Sumanth.

  • Sumanth,

    OK, I don't want us to get sidetracked into debugging other things. Let's focus on your issue. In your previous message, you said RAM: 3 + 63 cycles: 456nsec(observed from Oscilloscope). I made a measurement on the F28002x with the FastRTS library. The device itself shouldn't matter, since the C28xCPU+FPU is the same and we're running assembly. I measured 46 cycles, slightly more than the 38 cycles mentioned in the user guide.

    See attached picture.

    Thanks,

    Sira