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.

Handling IQ math library and function in TMS320F28027 Piccolo microcontroller

Other Parts Discussed in Thread: TMS320F28027, CONTROLSUITE

Hi,

I am using Piccolo control stick TMS320F28027 and trying to develop time critical code for my application, using sample programs/examples provided in control suits for a given control stick (project-ContrinuouADC). I have included and added IQmath.lib and 2802x_IQmath_BootROMSymbols.lib and done all settings recommended in the 'C28x IQmath Library' pdf document. I have also included following line of statements in code

---------------

// Select the global Q value to use:

#define GLOBAL_Q 24 long GlobalQ = GLOBAL_Q; . #include <stdio.h> #include <stdlib.h> #include "IQmathLib.h"

_iq x, y, z; //global variable declaration 

---------------

When i am doing IQmath calculation e.g. _IQmpy(x,y) the code is working fine and getting expected results, but when i am trying to do trigonometric functions e.g. _IQsin(x) the code is not working. I have also tried the same by uncommenting the code segment in "F28027_FLASH_ContinuousADC.CMD" file which were reserved ROM for the inverse trigonometric iq function.

Is there any other adjustment I need to do, to incorporate iq math functions? Is there any need to do changes in the .cmd file? Do we need to include any other file.

Please help me to resolve this issue or atleast refer me some documents/material/literature to make it work.

-Rupesh

 

 

 

  • Referring to earlier post, for program code

    x = _IQ(0.5);

    y = _IQmpy(x, _IQ(0.5));

    z = _IQsin(y);

    Following errors are showing over console:

     

    undefined first referenced        

      symbol       in file             

     --------- ----------------        

     FS$$MPY   ./DSP2802x_CpuTimers.obj

     FS$$TOL   ./DSP2802x_CpuTimers.obj

    error: unresolved symbols remain

    error: errors encountered during linking; "ContinuousADC.out" not built

    and following errors are showing on compiler 'problems' tab :

    errors encountered during linking; "ContinuousADC.out" not built ContinuousADC line 0 1316454399530 170

    unresolved symbol FS$$MPY, first referenced in ./DSP2802x_CpuTimers.obj ContinuousADC line 0 1316454399530 168

    unresolved symbol FS$$TOL, first referenced in ./DSP2802x_CpuTimers.obj ContinuousADC line 0 1316454399530 169
    Pl give your expert suggestions to solve above issue.
    -Rupesh

  • rupesh wandhare said:
    Please help me to resolve this issue or atleast refer me some documents/material/literature to make it work.

    Rupesh,

    In controlSUITE (www.ti.com/controlsuite) there is an IQmath example that uses IQsin.  This would be a good place to start debugging the issue.

    C:\TI\controlSUITE\libs\math\IQmath\v160\examples_ccsv4\C\2803x

    Regards,

    Lori

  • rupesh wandhare said:

    undefined first referenced        

      symbol       in file             

     --------- ----------------        

     FS$MPY   ./DSP2802x_CpuTimers.obj

     FS$TOL   ./DSP2802x_CpuTimers.obj

    These symbols are not from IQ but from the runtime support library as described on this wiki page:  http://processors.wiki.ti.com/index.php/C28x_Compiler_Error_and_Warning_Messages

    Do you by chance have MATH_TYPE defined as FLOAT_MATH in the IQ header file (instead of IQ_MATH)

    #define   FLOAT_MATH     1
    #define   IQ_MATH        0

    #ifndef   MATH_TYPE
    #define   MATH_TYPE      IQ_MATH          <-------
    #endif

     

    Regards,

    Lori

     

     

  • Dear Lori,

    Thanks for your quick reply. I had adjusted IQmathLib.h file as follows to include IQ_MATH library functions   

    #ifndef __IQMATHLIB_H_INCLUDED__

    #define __IQMATHLIB_H_INCLUDED__

     

    #define   FLOAT_MATH     0

    #define   IQ_MATH        1        <----------

    #ifndef   MATH_TYPE

    #define   MATH_TYPE      IQ_MATH

    #endif

     

    #ifndef   GLOBAL_Q

    #define   GLOBAL_Q       24

    #endif

     

     

    #if MATH_TYPE == IQ_MATH

     

    typedef   long    _iq;

     

    #define   QG          GLOBAL_Q

    '

    '

    #define   Q24         24

    '

    '

     I have also checked the following defined functions for global 24 

     

    #if GLOBAL_Q == 24

    #define   _IQ(A)  _IQ24(A)

     

     

    #if GLOBAL_Q == 24

    #define   _IQsin(A)  _IQ24sin(A)

    #define   _IQmpy(A,B)         ((A) * (B))  // for IQ variables

     

    But i have found one more bug, added IQmath.lib file is not showing arrow in my project: 'ContinuousADC'  unlike other files. I have also run sample program suggested by you (28027_IQsampleC), there the added  IQmath.lib file is showing arrow and all IQmath syntax are working fine. I have also tried to link the IQmath.lib file from other projects, though arrow shown but failed to build .obj with same error. What is significance of that arrow? How to obtained it. (I have done same procedure given in the 'C28x IQmath Library' pdf.)    

    I am working for the project to load program in FLASH (time critical code copy to RAM in main), I m using following .cmd file. 

     

    MEMORY

    {

    PAGE 0:

     BOOT_RSVD   : origin = 0x000000, length = 0x000050     /* Part of M0, BOOT rom will use this for stack */

    progRAM : origin = 0x008000, length = 0x000800

    OTP         : origin = 0x3D7800, length = 0x000400     /* on-chip OTP */

    FLASHD      : origin = 0x3F0000, length = 0x002000     /* on-chip FLASH */

    FLASHC      : origin = 0x3F2000, length = 0x002000     /* on-chip FLASH */

    FLASHA      : origin = 0x3F6000, length = 0x001F80     /* on-chip FLASH */

    CSM_RSVD    : origin = 0x3F7F80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */

    BEGIN       : origin = 0x3F7FF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to Flash" bootloader mode. */

    CSM_PWL     : origin = 0x3F7FF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA */

    IQTABLES    : origin = 0x3FE000, length = 0x000B50     /* IQ Math Table in Boot */

    IQTABLES2   : origin = 0x3FEB50, length = 0x00008C     /* IQ Math Table in Boot */

    IQTABLES3   : origin = 0x3FEBDC, length = 0x0000AA     /* IQ Math Table in Boot */

     

    BOOTROM     : origin = 0x3FF27C, length = 0x000D44     /* Boot ROM */

    RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM  */

    VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM  */

     

    PAGE 1 : 

     

    RAMM0       : origin = 0x000050, length = 0x0003B0

    RAMM1       : origin = 0x000400, length = 0x000400

    dataRAM : origin = 0x008800, length = 0x000800

    FLASHB      : origin = 0x3F4000, length = 0x002000

    }

    SECTIONS

    {

       .cinit               : > FLASHA,     PAGE = 0

       .pinit               : > FLASHA,     PAGE = 0

       .text               : > FLASHA,     PAGE = 0

     

       codestart           : > BEGIN       PAGE = 0

       ramfuncs            : LOAD = FLASHA, 

                             RUN = progRAM, 

                             LOAD_START(_RamfuncsLoadStart),

                             LOAD_END(_RamfuncsLoadEnd),

                             RUN_START(_RamfuncsRunStart),

                             PAGE = 0

     

       csmpasswds          : > CSM_PWL     PAGE = 0

       csm_rsvd            : > CSM_RSVD    PAGE = 0

     

       .stack           : > RAMM0,      PAGE = 1

       .ebss            : > dataRAM,    PAGE = 1

       .esysmem         : > dataRAM,      PAGE = 1

       .econst             : > FLASHA      PAGE = 0

       .switch             : > FLASHA      PAGE = 0      

     

       /* Allocate IQ math areas: */

       IQmath              : > FLASHA      PAGE = 0                  /* FLASHA Math Code */

       IQmathTables        : > IQTABLES    PAGE = 0, TYPE = NOLOAD   /* Math Tables In ROM */

       IQmathTables2    : > IQTABLES2, PAGE = 0, TYPE = NOLOAD 

       {

                   IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)

        }

        IQmathTables3    : > IQTABLES3, PAGE = 0, TYPE = NOLOAD 

       {

                     IQmath.lib<IQNasinTable.obj> (IQmathTablesRam)

        }   

        .reset              : > RESET,      PAGE = 0, TYPE = DSECT

       vectors             : > VECTORS     PAGE = 0, TYPE = DSECT

    }    

    SECTIONS

    {

    Net_terminals: > dataRAM,PAGE = 1

    }

     

     

  • rupesh wandhare said:
    But i have found one more bug, added IQmath.lib file is not showing arrow in my project: 'ContinuousADC'  unlike other files.

    I'm sorry, I don't  understand.  What arrow?

    The error in the screenshot means that within the DSP2802x_CpuTimers.c file there are two operations that require functions from the runtime support library.  Have you added the runtime support library to the build? Please refer to the wiki links I provided earlier.

    -Lori

     

  • Dear Lori,

    Thank you so much for your help and strong TI support. I have referred "http://processors.wiki.ti.com/index.php/C28x_Code_Generation_Tips_and_Tricks#Run-Time_Support_Library" as suggested by you. I found, 'rts2800_ml.lib' was missing from my project. I have included it, now project is working.

    For update: The arrow over file IQmath.lib were missing as shown in the following screenshot. After adding 'rts2800_ml.lib', arrow has shown over the same file.

    I have indicated it with black circle (while other files are showing arrow, shown by blue small circles) before adding above file in the project.

    -Rupesh

     


  • rupesh wandhare said:
    For update: The arrow over file IQmath.lib were missing as shown in the following screenshot. After adding 'rts2800_ml.lib', arrow has shown over the same file.

    Ah thanks I understand now.  The little up-arrow indicates the file is a linked resource.   It does not indicate a problem with the file or library.

    It is a bit involved to explain, but there is more information on this wiki page regarding what a linked resource is (it is like a shortcut or UNIX linked file).

    http://processors.wiki.ti.com/index.php/Portable_Projects

    Regards

    Lori