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.

TMS320F280049: Unexpected time consumption in our code: assembly file attached

Part Number: TMS320F280049

Hi expert,

My cusomter find exteremely long execution time for some code pieces and would like us to review this part. Could you help us with it? (measured time consumption is marked in the comment)

 

#define PI_VALUE 3.141592653589

 

float32_t Phase_IO_AC;

float degree2_radian_DS3;

 

…………..

        if ((Phase_IO_AC > 0) && (Phase_IO_AC < degree1_radian_DS3)) // 17 system clocks consumed

        {

            ++toDel1;

        }

        else if ((Phase_IO_AC > (PI_VALUE - degree1_radian_DS3)) && (Phase_IO_AC < (PI_VALUE + degree1_radian_DS3))) // 464 system clocks consumed

        {

            ++toDel1;

        }

        else if ((Phase_IO_AC > (6.2832 - degree1_radian_DS3)) && (Phase_IO_AC < 6.2832))  // 364 system clocks consumed

        {

            ++toDel1;

        }

        else if ( (Phase_IO_AC > degree2_radian_DS3) && (Phase_IO_AC < (PI_VALUE - degree2_radian_DS3)) ) // 364 system clocks consumed

        {

            ++toDel1;

        }

………………

 Isr.asm

Thanks

Sheldon

 

  • Hi Sheldon,

    Is the customer running this on C28x or CLA? I see from the asm file that you are not using FPU32 instructions for the subtraction operations. Can you try that and revert back?

    -Shantanu

  • Hi Shanty,

    My customer is running it on C28x and we have checked that FPU32 is enabled here. Do we have other things to check here?

    Thanks

    Sheldon

  • Hi,

    I see the DIV2PIF32 and SINPUF32 instructions being called in some of the IF loops. Can you try the following:

    1) Include FASTRTS library, add TMU support and try

    2) Just for testing purposes, instead of making PI a macro, can you make it a float_32 and try? Let me know if there is a change in the cycles.

    I would like to replicate it on my machine. Could you share the project settings and initial value of degree1_radian_DS3?

    -Shantanu

  • Hi Shantanu,

    degree1_radian_DS3 has initial value of 0.34907.

    Project file.zip

    Project file is attached here.

    We will try your recommendation at our side.

    Thanks

    Sheldon

  • #define PI_VALUE 3.141592653589

    An unsuffixed floating point constant is implicitly type double.

    When such constants are used in expressions with variables of type float the expression is promoted to use double precision. On a TMS320F280049 with --abi=eabi double is 64-bits and use of double precision calculations causes software library routines to be used, as the TMS320F280049 only has single precision (32-bits) FPU hardware support.

    If a 'f' suffix is used for floating point constants they are of type float and expressions using the constants can then be done using single precision with the FPU.

    I.e. try changing the code to make the floating point constants of type float:

    #define PI_VALUE 3.141592653589f
    
     
    
    float32_t Phase_IO_AC;
    
    float degree2_radian_DS3;
    
     
    
    …………..
    
            if ((Phase_IO_AC > 0) && (Phase_IO_AC < degree1_radian_DS3))
    
            {
    
                ++toDel1;
    
            }
    
            else if ((Phase_IO_AC > (PI_VALUE - degree1_radian_DS3)) && (Phase_IO_AC < (PI_VALUE + degree1_radian_DS3)))
    
            {
    
                ++toDel1;
    
            }
    
            else if ((Phase_IO_AC > (6.2832f - degree1_radian_DS3)) && (Phase_IO_AC < 6.2832f))
    
            {
    
                ++toDel1;
    
            }
    
            else if ( (Phase_IO_AC > degree2_radian_DS3) && (Phase_IO_AC < (PI_VALUE - degree2_radian_DS3)) )
    
            {
    
                ++toDel1;
    
            }
    
    ………………