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.

CCS/TMS320F28069: Using Math Tables in CLA and FPU

Part Number: TMS320F28069
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

I have an F28069 device and am trying to get the math LUT tables into the CLA, but without much success.

I have specified cla1_math_library_fpu32.lib in project properties and pointed the linker to all locations it needs to know.  I also have the relevant sections in the cmd file (see below) and code to copy the tables into the CLARAM1 during startup.  The project compiles without error.

But somehow I need to put the math tables into the FLASH in the first place, as at present the FLASHH area allocated to store them is empty.  I do not know where to find the math tables in the C2000 compiler installation or how to link/reference/install them into my project. So, where are they and how to get at them?

Also, is a similar process needed to use LUTs with the FPU?

Many thanks in advance.

The relevant part of the cmd file is as follows:

 /* Allocate CLA areas: */
   Cla1Prog        : > RAML3,
                     LOAD_START(_Cla1funcsLoadStart),
                     LOAD_END(_Cla1funcsLoadEnd),
                     LOAD_SIZE(_Cla1funcsLoadSize),
                     RUN_START(_Cla1funcsRunStart),
                     PAGE = 0
   Cla1ToCpuMsgRAM  : > CLA1_MSGRAMLOW,   PAGE = 1
   CpuToCla1MsgRAM  : > CLA1_MSGRAMHIGH,  PAGE = 1
   Cla1DataRam0  : > CLARAM0,    PAGE = 1
   Cla1DataRam1  : > CLARAM1,    PAGE = 1
   Cla1DataRam2  : > CLARAM2,    PAGE = 1
   ClaDataRamL  : > RAML5,      PAGE=1
   /* Load tables to Flash and copy over to RAM */
   Cla1mathTables    : LOAD = FLASHH,
                       RUN = CLARAM1,
                       LOAD_START(_Cla1mathTablesLoadStart),
                       LOAD_SIZE(_Cla1mathTablesLoadSize),
                       RUN_START(_Cla1mathTablesRunStart),
                       PAGE = 1
   CLAscratch       :
                     { *.obj(CLAscratch)
                     . += CLA_SCRATCHPAD_SIZE;
                     *.obj(CLAscratch_end) } > CLARAM0,
      PAGE = 1
  • Andrew,

    I’ll work with you to try and resolve this issue. Please give me until Monday to get back to you with an update.

    Thanks,
    Sira
  • Andrew,

    The F2806x device should have CLA Math tables in Boot ROM. Have you read Section 4.4 of the CLA Math Library User's Guide on"Using the Tables in the CLA Data ROM"? Essentially, if the tables are in Boot ROM, you don't have to load the tables into Flash and subsequently copy them over to RAM at runtime. One of the key symbols of interest is CLA_MATH_TABLES_IN_ROM. Check if it is defined (as 1) in either your linker command file or defined in project properties C2000 Linker->command file preprocessing-> --define

    Thanks,
    Sira
  • Andrew,

    Did that resolve your issue? If yes, can you please go ahead and click the "Verified Answer" button?

    Thanks,
    Sira
  • Hi Sira,

    Thanks for your reply - sorry I couldn't answer sooner, I haven't had time to look at this due to another matter. Anyway...yes, I realise that some devices already have the math tables stored in boot ROM, which eliminates the need to store them in FLASH and copy to RAM at runtime. However, in section 4.2 of the CLA Math Library User's Guide, it states this (in red):

    NOTE: THE F2806X DOES NOT HAVE A CLA DATA ROM, THEREFORE, THE DATAROM VARIANT OF THE MATH LIBRARY CANNOT BE USED

    I have temporarily got around this by doing trig operations in the FPU, but it would be helpful to know how to put the tables in FLASH so that I can do trig in the CLA. I understand how to allocate FLASH in the linker file and copy that to RAM at runtime, but I need to know how to put the tables into FLASH in the first place.

    Many thanks,

    Andrew
  • Andrew,

    Good catch on that special note in the UG about 2806x devices. Looks like you will have to go with the Flash->RAM approach for this device.

    Anyway, the short answer to your question is this - the tables are available in the CLA1_math_library project (in the various files named xxxTable.asm), so when the CLA1_math_library_fpu32.lib is included in your project, the Linker will find the tables in the library and store them in the Flash location specified in the Linked command file, and at run time, they will be loaded to the RAM location specified in the Linker command file. As a user, you don't need to do anything more. My guess is if you setup everything correctly (including library, choosing the right build configuration etc.), your project should be working properly and using the CLA tables and generating the right results already.

    There is a lot that can be learnt from the examples in C:\ti\c2000\C2000Ware_1_00_06_00\libraries\math\CLAmath\c28\examples. For example, I loaded the cla_asin project. This has various build configurations for various devices, and within a device, for FLASH, RAM etc. I chose the f2806x_FLASH build configuration. Then if you expand f2806x in the project view, you'll see the linker command file f2806x_cla_c_lnk.cmd. Here, you'll see that if the FLASH build configuration is being used, CLA1mathTables must be loaded into FLASHB (origin 0x3F0000) and run from CLARAM1 (origin 0x008C00).

    You'll also see from Project Properties -> C2000 Linker -> Advanced Options -> Command File Preprocessing -> --define that CLA_MATH_TABLES_IN_ROM is not defined, which means the tables are not in ROM for this device (or that option is not being used).

    Now if you build the project, and open cla_asin.map (located when you expand f2806x_FLASH in the project view), you'll see the following:
    CLA1mathTables
    * 1 003f0000 0000030e RUN ADDR = 00008c00
    003f0000 0000018a cla0_math_library_fpu32.lib : CLAasineTable.obj (CLA1mathTables)

    The above indicates the tables are loaded in FLASHB (Origin 0x3f0000).

    and also further down the .map file:

    1 00008c00 _CLAasinHalfPITable
    1 00008c04 _CLAasinTable

    The above indicates the tables are copied to CLARAM1 (Origin 0x008C00).

    Just to experiment further, I made the following change in cla_asin.cla:

    __attribute__((interrupt)) void Cla1Task1(void)
    {
    __mdebugstop();
    fResult1 = CLAasin(fVal);
    fResult1 = CLAacos(fVal);
    }

    __attribute__((interrupt)) void Cla1Task2(void)
    {
    //
    // Test inline function
    //
    __mdebugstop();
    fResult2 = CLAasin_inline(fVal);
    fResult2 = CLAacos_inline(fVal);
    }

    Now if you build the cla_asin project and inspect cla_asin.map, you'll see the following:

    CLA1mathTables
    * 1 003f0000 0000030e RUN ADDR = 00008c00
    003f0000 0000018a cla0_math_library_fpu32.lib : CLAasineTable.obj (CLA1mathTables)
    003f018a 00000184 : CLAacosineTable.obj (CLA1mathTables)

    and also further down the .map file:
    1 00008c00 _CLA1mathTablesRunStart
    1 00008c00 _CLAasinHalfPITable
    1 00008c04 _CLAasinTable
    1 00008d8a _CLAacosinHalfPITable
    1 00008d8a _CLAasinTableEnd
    1 00008d8e _CLAacosinTable
    1 00008f0e _CLAacosinTableEnd

    I hope this clears up things for you.

    Thanks,
    Sira
  • Andrew,

    To finish up my previous post, I meant to mention that it appears that only the tables that are needed by the project are loaded into Flash and then copied to RAM. This was the intent of me modifying the cla_asin project to include the CLAacos() function call.

    Thanks,
    Sira
  • Hi Sira,

    Thank you very much for your detailed reply.  I think the critical bit is knowing that the "CLA1mathTables" section is specified in the "xxxTable.asm" files as well as in the .cmd file, which explains how the tables magically appear in the right place in FLASH when required.

    Many thanks again,

    Andrew