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.

TMS320F28377D-EP: Not able to perform fast integer division

Part Number: TMS320F28377D-EP


Hello,

I am not able to perform fast integer division. I tried the following code below:

#include <stdlib.h>

int16_t testresult = 0;
testresult = __traditional_div_i16byi16(1,1);

And i get this error:
#515 a value of type "ldiv_t" cannot be assigned to an entity of type "int16_t"

Any idea why is this happening?

I have enabled --idiv0_support:

-v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --idiv_support=idiv0 --tmu_support=tmu0 --vcu_support=vcu2 -O4 --opt_for_speed=5 --fp_mode=relaxed --fp_reassoc=on --

I am not able to use any of these:

  • Hello Arun,

    And i get this error:
    #515 a value of type "ldiv_t" cannot be assigned to an entity of type "int16_t"

    Any idea why is this happening?

    The result of the function is not the same datatype as int16_t, exactly what the error says. The result returned uses the ldiv_t datatype. The ldiv_t datatype is created in the stdlib.h file from the 'int' datatype, so you can try to manually cast it and see if that works (otherwise you may need a bigger datatype such as int32_t).

    I am not able to use any of these:

    Can you clarify what you mean by this? Is it that you're getting the same error, or the compiler doesn't even recognize that those functions exist?

  • Hi Omer,

    I tried setting the data type to Idiv_t:

    #include <stdlib.h>
    
    Idiv_t testresult = 0;
    testresult = __traditional_div_i16byi16(1,1);

    But Idiv_t, itself is not defined, I get this error:

    #20 identifier "Idiv_t" is undefined.

    Lokking at the function definitions a bit closely i forgot the '.quot' at the end.

    When i tried this:

    #include <stdlib.h>
    
    int16_t testresult = 0;
    testresult = __traditional_div_i16byi16(1,1).quot;

    The code does compile but the division is not performed. The value of testresult is always 0!!

  • Based on your code attached here, it looks like you typed a capital 'i' instead of a lowercase 'l' ('L'). You can check the stdlib.h file to be sure.

  • Thanks , i overlooked the mistyped error.