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.

Trigonometric functions on a TM4C129X

Hi there,

The Tiva TM4C MCUs have floating point capability.  I would like to utilise this FP capability when I calculate trigonometric functions.  

  1. Is the recommended option to use the IQ Math package ? http://www.ti.com/tool/sw-tm4c-iqmath
  2. As per the user guide [1]  "The IQmath library uses a 32-bit fixed-point signed number (a “long” in C) as its basic data type."   Why does the TIVA  IQ Math package not use FP ? Wouldn't that be more efficient on an architecture that supports it ?  
  3. The basic file IQmathLib.h to include is not even present in the release I downloaded from the above link.  It is supposed to be there as per the filelist.txt.  Instead there is a template file named IQmath\templates\IQmathLib.h.tmpl yet I am not instructed to delete the tmpl extension for all the *.tmpl files.  Should I ?

regards

Peter

[1] C:\ti\TivaWare_C_Series-2.1.0.12573\docs\SW-TM4C-IQMATH-UG-2.1.0.12573.pdf

  • Hello Peter,

    If you download the full package for TivaWare, i do see the file present. The web page is going to be restructured to ensure that all such scattered packages get replaced by a single good to use release.

    Yes, it is recommended to use the IQMath library and it would be more efficient as well in terms of variable representation. We can look into it but an updated IQMath may not be available that soon.

    Regards
    Amit
  • Hello Peter and Amit,

    Unless you need more that 24-bits of mantissa, the FPU option is the way to go - faster and no need to plan/manage scale factors. While the IQ library was a helpful tool in the non-FPU world, it is definitely 2nd choice with modern FPU-bearing processors.

    Regards,
    Dave
  • Hi,

    1. Yes and no, depends on your application.

    2a. If I remember well, the same documents (or even the source code) states somewhere that to use fixed point, you must add some #define, otherwise the calculations are done in fp. (I did not used/checked that, but you may search if it is true).

    2b. Take a look also at CMSIS library, there are some functions with fp...

    2c. Depending on your project, look (google) for CORDIC algorithms, to implement faster trig functions (fp, C code available).

    Petrei

  • Hi Petrei - Great to see you here!

    Like your comments - and that CORDIC mention (which I had forgotten) will see our use this weekend. Thank you!
  • Amit, thanks for pointing out where to find the IQmath library, I discovered that not long after posting !
  • Thanks Petrei. Are you suggesting the default config of IQmath is floating point ? My statement above from the manual appears to be the default setting.
  • Dave. It appears IQmath does support FP with
    #define MATH_TYPE FLOAT_MATH

    WIll that definately ensure the FP part of the TM4CX is utilised ?
  • Hello Peter,

    You can check the same by querying the NVIC_CPACC register to see CP11 and CP10 indicate full access.

    Regards
    Amit
  • Amit Ashara said:
    You can check the same by querying the NVIC_CPACC register to see CP11 and CP10 indicate full access.

    Thanks Amit, On my TM4C129X, registers CP11 and CP110 both return 0x3 indicating full access.  This means CCS will take advantage of the Floating Point co-processor when compiling the IQmath library.

    NVIC_CPAC 0x00F00000 Coprocessor Access Control [Memory Mapped]
       NVIC_CPAC_CP11 0x3 (Hex) CP11 Coprocessor Access Privilege
       NVIC_CPAC_CP10 0x3 (Hex) CP10 Coprocessor Access Privilege

  • As far more here use the TM4C123x series - might someone check & report its status - as regards such, "full, flotating point access?"
  • p. 11 of the IQmath document (SW-TM4C-IQMATH-UG-2.1.0.12573.pdf) has functions to convert between its native fixed point datatypes and single and double precision floating point numbers.  Those operations take up non trivial number of execution cycles (20) and I wonder if that goes some way to negating the efficiency of requesting IQmath to utilise the floating Point co-processor.

    It would also be much nicer if IQmath was re-written to use natively use double precision floating point data types, that way I don't keep having to a multiplicity of _IQn data types depending on the range and resolution of each variable I declare.

    Below I copied relevant sections of the manual.