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.

TMS320F28379D: COFF to EABI project with stdlib.h included double to float conversion

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Hi! 

I am trying to convert my very simple project from COFF file format to EABI format. 

I have managed to build it after "F28x_usDelay" to "_F28x_usDelay" replacement. But I get dozens of these warnings:

#3195-D (Performance) EABI double precision is 64-bits as opposed to 32-bits for COFF. Consider changing doubles to floats for improved performance in FPU32-mode.

for stdlib.h (which is located at C2000 compiler folder and I presume editing it directly is not the brightest idea) fragments, such as:

#ifdef _INLINE

static __inline double atof(const char *_st)
{
return strtod(_st, (char **)0);
}

#endif /* _INLINE */

This build runs on the MCU, but nearly 10 times slower in comparison with COFF version (verified via pin-and-oscilloscope measurement). I have read EABI to COFF migration tutorial and understood that the problem is in 64-bits floats instead of 32-bit ones. I have tried to switch --float_operations_allowed compiler key to 32-bit only operations and have got build errors for the same code fragments:

#1558-D 64-bit floating point operations are not allowed

What should I do to overcome this problem? Is there any designated solution? May be I should point compiler to another stdlib.h version? 

I am running Code Composer Studio 10.1.0.00010 at Linux Mint 20.1 with  C2000Ware_3_04_00_00_Software installed. My compiler is TI v20.2.4.LTS.

Thanks in advance! 

  • Hi,

    Please add "F" suffix to all float constants. For example, if you have 2.0 * var, please update that to 2.0F. The EABI compiler will treat 2.0 as 64 bit float constant and uses 64 bit floating operations, Since this device does not have FPU64 accelerator, these operations will be time consuming. Adding the "F" suffix makes the compiler treat 2.0 as  32-bit float.

    Also, strtod uses double data type. Double is 64 bit in EABI and 32 bit in COFF. You can use strtof instead.

    What you did with the --float_operations_allowed flag is the right approach. It will point out the places where compiler trues to do a 64 bit floating point operation.

    Regards,

    Veena

  • Hi!

    I have added F to all float numbers and it does not provide any improvement. The error is appearing when math functions from #include <math.h> are used. Fragment with strtod function is not from my source, but from stdlib.h file, and it is used for math functions if I understand correctly.

    Steps to reproduce:

    1) Use any project of standard bitfield examples

    2) Add #include <math.h> to first include lines

    3) Add float a=25.540; round(a);

    4) Compile. See no error

    5) Switch project properties and runtime support library to EABI and set "Build -> C2000 Compiler -> Advanced Options -> Language Options -> Floating point precision ..." to allow 32 bit only floating point operation.

    6) In "F28379xD_examples.h" file find DELAY_US macro and add underscore ("_") symbol before F28x_Delay function call. This solves symbol not found error and allows successful compilation

    7) Try to compile. See multiple errors for DELAY_US macro using long operations and error for round function.

    This is not obvious and not described in migration guide -- https://software-dl.ti.com/ccs/esd/documents/C2000_c28x_migration_from_coff_to_eabi.html

    Also if I understand correctly DELAY_US macro should (and can) be modified to use 32-bit only math operations.

    From Russia with love, Dmitry

    P.S. Sorry for a very long reply. This forums does not allow me to answer directly and at all, as seen here https://e2e.ti.com/support/site-support/f/site-support-forum/990450/cannot-reply-to-my-own-thread/3658951#3658951

    P.P.S. Restriction of forum posting access for corporate-and-approved-email only people is extremely discriminating and ugly. I am legit post-graduate student and my extra-large Federal University does not provide corporate e-mail address for students. So I am denied from professional community? This is unfair to all of the non-USA and non-Europe people.

  • Hi Dmitry,

    round function operates on double type. Can you try using roundf, which is the equivalent function for float datatype.

     

    Regards,

    Veena

  • Hi, Veena!

    I have tried replacing all floating math functions (round, floor, ceiling) with their single-precision versions (roundf, floorf, ceilingf) and I have got remarkable computation speed boost. Now the code has approximately the same speed as in COFF version with round, floor, ceiling functions. Currently there are only 2 functions which give an 64-bit math error:

    1) US_DELAY macro, which is based on long float type. Is there any version of it for EABI 32-bit-only projects?

    2) atof() function. It has "f" in name, so float result is expected. In fact, it depends on double type and strtod function, as seen in starter-post. I have checked that atoff() function does not exist, so what is correct approach to string to float conversion in EABI projects?

    Thank you for your very appreciated help!

    P.S. This situation is quite embarrassing, since one would expect to see these changes in migration guide document as a table. And atof() should really be 32-bit float function, as name suggests. Current atof() function should be renamed to atod() function, if I understand correctly.

    P.P.S. This forum is extremely useful, but if it denies diversity of people from all over the world, who do not have e-mail account associated with University known by TI. I am very sorry for writing this here, but this forum does not allow me to express myself in more correct place.

    P.P.P.S. Mathworks have great approach for their MATLAB student licenses (in Russia at least) --- they request student ID and verify it via their local partner as alternative identification form. This approach is way better, than demand solely on corporate e-mails.

  • Hi Dmitriy,

    I regret to hear that you have issues in using the forum. I have forwarded your concern to the E2E team. If you able to post queries, please post the same here -> https://e2e.ti.com/support/site-support/f/site-support-forum

    At present, we do not have a version of DELAY_US macro which does not use double data type.

    For time-being, you can use the function F28x_usDelay directly. But it takes the loopcount as parameter, instead of the time in us. You may need to compute the loopcount based on the CPU frequency and the function latency. The details are available in the usDelay.asm file. You can use DELAY_US macro definition as a reference for this calculation.

    I will check with compiler experts on the atof function and get back to you.

    Regards,

    Veena

  • Meanwhile, can you use the function strtof instead of atof?

    Regards,

    Veena