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: CLA中三角函数计算问题

Part Number: TMS320F28377D

Hello!在线调试下(连着仿真器运行):CLAsinCLAcos的三角运算正常。程序烧到FLASH中脱开仿真器运行时:三角函数CLAsin,CLAcos运算结果一直是0。但是CLAdiv和CLAsqrt的计算结果都是正确的,程序中添加的库和clasincostable的使用方法如附件。7433.CLA中CLAsin和CLAcos运算问题.pdf

  • 您好我们已收到您的问题并升级到英文论坛,温馨提示您由于圣诞及新年假期,英文论坛的答复将稍晚。敬请谅解!

  • 您好,您是说应用程序是在debug模式下运行, 而不是在standalone模式下运行?

    如果是Flash config, 您需要确保 CLA 代码和常量加载到了闪存中并复制到 RAM 中。 从您提供的信息来看, .const_CLA 部分直接加载到 RAM 存储器中, 这些值在加电复位后会丢失.

  • 您的问题1:您是说应用程序是在debug模式下运行, 而不是在standalone模式下运行?

    回答问题1:CPU1设定在Release模型下运行

    您的问题2:如果是Flash config, 您需要确保 CLA 代码和常量加载到了闪存中并复制到 RAM 中。

    回答问题2:是Flash 配置,我们已经可以离线跑程序了,实现了其他功能,比如开根号,除法运算等,仅仅三角函数运算不对,这样是否可以说明代码加载到闪存并复制到RAM中是成功的?

    CLA的代码和常量加载到闪存并复制到RAM中的代码如下所示:

    #if defined(__TI_EABI__)
    Cla1Prog : LOAD = FLASHA_M,
    RUN = RAMLS0123,
    LOAD_START(Cla1funcsLoadStart),
    LOAD_END(Cla1funcsLoadEnd),
    RUN_START(Cla1funcsRunStart),
    LOAD_SIZE(Cla1funcsLoadSize),
    PAGE = 0, ALIGN(8)
    #else
    Cla1Prog : LOAD = FLASHA_M,
    RUN = RAMLS0123,
    LOAD_START(_Cla1funcsLoadStart),
    LOAD_END(_Cla1funcsLoadEnd),
    RUN_START(_Cla1funcsRunStart),
    LOAD_SIZE(_Cla1funcsLoadSize),
    PAGE = 0, ALIGN(8)
    #endif

    CLA1mathTables : > RAMLS45, PAGE = 1

    CLA1mathTables : LOAD = FLASHA_M,
    RUN = RAMLS45,
    RUN_START(_CLA1mathTablesRunStart),
    LOAD_START(_CLA1mathTablesLoadStart),
    LOAD_SIZE(_CLA1mathTablesLoadSize),
    PAGE = 1

    memcpy((uint32_t *)&Cla1funcsRunStart, (uint32_t *)&Cla1funcsLoadStart,(uint32_t)&Cla1funcsLoadSize);
    memcpy((uint32_t *)&CLA1mathTablesRunStart, (uint32_t *)&CLA1mathTablesLoadStart,(uint32_t)&CLA1mathTablesLoadSize);

    同时给出CPU代码从flash中复制到RAM中的代码如下:

    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);

    #ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
    #if defined(__TI_EABI__)
    .TI.ramfunc : {} LOAD = FLASHA_M,
    RUN = RAMGS8_13,
    LOAD_START(RamfuncsLoadStart),
    LOAD_SIZE(RamfuncsLoadSize),
    LOAD_END(RamfuncsLoadEnd),
    RUN_START(RamfuncsRunStart),
    RUN_SIZE(RamfuncsRunSize),
    RUN_END(RamfuncsRunEnd),
    PAGE = 0, ALIGN(8)
    #else
    .TI.ramfunc : {} LOAD = FLASHA_M,
    RUN = RAMGS8_13,
    LOAD_START(_RamfuncsLoadStart),
    LOAD_SIZE(_RamfuncsLoadSize),
    LOAD_END(_RamfuncsLoadEnd),
    RUN_START(_RamfuncsRunStart),
    RUN_SIZE(_RamfuncsRunSize),
    RUN_END(_RamfuncsRunEnd),
    PAGE = 0, ALIGN(8)
    #endif
    #else
    .TI.ramfunc : LOAD = FLASHA_M,
    RUN = RAMGS8_13,
    LOAD_START(_RamfuncsLoadStart),
    LOAD_SIZE(_RamfuncsLoadSize),
    LOAD_END(_RamfuncsLoadEnd),
    RUN_START(_RamfuncsRunStart),
    RUN_SIZE(_RamfuncsRunSize),
    RUN_END(_RamfuncsRunEnd),
    PAGE = 0, ALIGN(8)
    #endif
    #endif

    您的问题3:从您提供的信息来看, .const_CLA 部分直接加载到 RAM 存储器中, 这些值在加电复位后会丢失.

    回答问题3:您的意思是不是将  .const_cla       : > RAMLS45,       PAGE = 1 修改如下:

    .const_cla : LOAD = FLASHA_M,
    RUN = RAMLS0123,
    RUN_START(_Cla1ConstRunStart),
    LOAD_START(_Cla1ConstLoadStart),
    LOAD_SIZE(_Cla1ConstLoadSize),
    PAGE = 0

  • // The user must define CLA_C in the project linker settings if using the
    // CLA C compiler
    // Project Properties -> C2000 Linker -> Advanced Options -> Command File
    // Preprocessing -> --define
    #ifdef CLA_C
    // Define a size for the CLA scratchpad area that will be used
    // by the CLA compiler for local symbols and temps
    // Also force references to the special symbols that mark the
    // scratchpad are.
    CLA_SCRATCHPAD_SIZE = 0x100;
    --undef_sym=__cla_scratchpad_end
    --undef_sym=__cla_scratchpad_start
    #endif //CLA_C
    
    MEMORY
    {
    PAGE 0 :
       /* BEGIN is used for the "boot to SARAM" bootloader mode   */
    
       BEGIN           	: origin = 0x080000,   length = 0x000002
    /*   RAMM0           	: origin = 0x000123,   length = 0x0002DD*/
       RAMD0           	: origin = 0x00B000,   length = 0x000800
       RAMD1            : origin = 0x00B800,   length = 0x000800
       
       RAMLS0123         : origin = 0x008000,   length = 0x002000
       
       RAMGS8_13       : origin = 0x014000,   length = 0x006000
    
    /*   RAMGS15          : origin = 0x01B000, length = 0x000FF8  */   /* Only Available on F28379D, F28377D, F28375D devices. Remove line on other devices. */
    
    //   RAMGS15_RSVD     : origin = 0x01BFF8, length = 0x000008    /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
       RESET           	: origin = 0x3FFFC0,   length = 0x000002
    
       /* Flash sectors */
    
       
       FLASHA_M         : origin = 0x080002,   length = 0x03DFFE  
       FLASHN           : origin = 0x0BE000,   length = 0x001FF0	/* on-chip Flash */
    
    //   FLASHN_RSVD     : origin = 0x0BFFF0, length = 0x000010    /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
    
    PAGE 1 :
    
       BOOT_RSVD       : origin = 0x000002, length = 0x000121     /* Part of M0, BOOT rom will use this for stack */
    /*   RAMM1           : origin = 0x000400, length = 0x0003F8 */     /* on-chip RAM block M1 */
       RAMM01          : origin = 0x000123, length = 0x0006DE  /* on-chip RAM */
    //   RAMM1_RSVD      : origin = 0x0007F8, length = 0x000008     /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
    /*   RAMLS2      		: origin = 0x009000,   length = 0x000800*/
    /*   RAMLS3      		: origin = 0x009800,   length = 0x000800*/
       
       RAMLS45      	: origin = 0x00A000,   length = 0x001000
    
       RAMGS2_7         : origin = 0x00E000,   length = 0x006000
       
    //   RAMGS11          : origin = 0x017000, length = 0x000FF8   /* Uncomment for F28374D, F28376D devices */
    
    //   RAMGS11_RSVD     : origin = 0x017FF8, length = 0x000008    /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
    
       EMIF1_CS0n       : origin = 0x80000000, length = 0x10000000
       EMIF1_CS2n       : origin = 0x00100000, length = 0x00200000
       EMIF1_CS3n       : origin = 0x00300000, length = 0x00080000
       EMIF1_CS4n       : origin = 0x00380000, length = 0x00060000
       EMIF2_CS0n       : origin = 0x90000000, length = 0x10000000
       EMIF2_CS2n       : origin = 0x00002000, length = 0x00001000
    
       CLA1_MSGRAMLOW   : origin = 0x001480,   length = 0x000080
       CLA1_MSGRAMHIGH  : origin = 0x001500,   length = 0x000080
    
       CPU2TOCPU1RAM   : origin = 0x03F800, length = 0x000400
       CPU1TOCPU2RAM   : origin = 0x03FC00, length = 0x000400
    }
    
    
    SECTIONS
    {
       /* Allocate program areas: */
       .cinit           : > FLASHA_M      PAGE = 0, ALIGN(8)
       .text            : > FLASHA_M      PAGE = 0, ALIGN(8)
       codestart        : > BEGIN       PAGE = 0, ALIGN(8)
       .stack           : > RAMM01       PAGE = 1
       .switch          : > FLASHA_M      PAGE = 0, ALIGN(8)
    
       /* Allocate uninitalized data sections: */
    
    #if defined(__TI_EABI__)
       .init_array         : > FLASHA_M,       PAGE = 0, ALIGN(8)
       .bss                : > RAMM01 | RAMLS45,       PAGE = 1
       .bss:output         : > RAMM01 | RAMLS45,       PAGE = 1
       .data               : > RAMM01 | RAMLS45,       PAGE = 1
       .sysmem             : > RAMM01 | RAMLS45,       PAGE = 1
       .const              : > FLASHA_M,       PAGE = 0, ALIGN(8)
    #else
       .pinit              : > FLASHA_M,       PAGE = 0, ALIGN(8)
       .ebss               : > RAMGS2_7,		 PAGE = 1
       .esysmem            : > RAMGS2_7,       PAGE = 1
       .econst             : > FLASHA_M   	 PAGE = 0, ALIGN(8)
    #endif
    
       .reset           : > RESET,     PAGE = 0, TYPE = DSECT /* not used, */
    
       Filter_RegsFile  : > RAMGS2_7,	   PAGE = 1
       
       .em2_cs0         : > EMIF2_CS0n, PAGE = 1
       .em2_cs2         : > EMIF2_CS2n, PAGE = 1
    
      CLA1mathTables    : > RAMLS45,              PAGE = 1
    
      CLA1mathTables    :  LOAD = FLASHA_M,
                            RUN = RAMLS45,
                            RUN_START(_CLA1mathTablesRunStart),
                            LOAD_START(_CLA1mathTablesLoadStart),
                            LOAD_SIZE(_CLA1mathTablesLoadSize),
                            PAGE = 1
    
        /* CLA specific sections */
       #if defined(__TI_EABI__)
       		Cla1Prog    : LOAD = FLASHA_M,
                          RUN = RAMLS0123,
                          LOAD_START(Cla1funcsLoadStart),
                          LOAD_END(Cla1funcsLoadEnd),
                          RUN_START(Cla1funcsRunStart),
                          LOAD_SIZE(Cla1funcsLoadSize),
                          PAGE = 0, ALIGN(8)
       #else
          	Cla1Prog    : LOAD = FLASHA_M,
                          RUN = RAMLS0123,
                          LOAD_START(_Cla1funcsLoadStart),
                          LOAD_END(_Cla1funcsLoadEnd),
                          RUN_START(_Cla1funcsRunStart),
                          LOAD_SIZE(_Cla1funcsLoadSize),
                          PAGE = 0, ALIGN(8)
       #endif
    
    /*   CLADataLS0		: > RAMLS0, PAGE=0*/
    /*   CLADataLS1		: > RAMLS1, PAGE=0*/
       
       Cla1DataRam1	    : > RAMLS45,		  PAGE = 1
    
       Cla1ToCpuMsgRAM  : > CLA1_MSGRAMLOW,   PAGE = 1
       CpuToCla1MsgRAM  : > CLA1_MSGRAMHIGH,  PAGE = 1
    
    #ifdef __TI_COMPILER_VERSION__
       #if __TI_COMPILER_VERSION__ >= 15009000
            #if defined(__TI_EABI__)
    		    .TI.ramfunc : {} LOAD = FLASHA_M,
    							 RUN = RAMGS8_13,
                    	         LOAD_START(RamfuncsLoadStart),
                     	         LOAD_SIZE(RamfuncsLoadSize),
                     	         LOAD_END(RamfuncsLoadEnd),
                      	         RUN_START(RamfuncsRunStart),
                      	         RUN_SIZE(RamfuncsRunSize),
                       	         RUN_END(RamfuncsRunEnd),
    							 PAGE = 0, ALIGN(8)
    		#else
    			.TI.ramfunc : {} LOAD = FLASHA_M,
    							 RUN = RAMGS8_13,
                    	         LOAD_START(_RamfuncsLoadStart),
                     	         LOAD_SIZE(_RamfuncsLoadSize),
                     	         LOAD_END(_RamfuncsLoadEnd),
                      	         RUN_START(_RamfuncsRunStart),
                      	         RUN_SIZE(_RamfuncsRunSize),
                       	         RUN_END(_RamfuncsRunEnd),
    							 PAGE = 0, ALIGN(8)
    		#endif
       #else
       .TI.ramfunc        : LOAD = FLASHA_M,
                          RUN = RAMGS8_13,
                          LOAD_START(_RamfuncsLoadStart),
                          LOAD_SIZE(_RamfuncsLoadSize),
                          LOAD_END(_RamfuncsLoadEnd),
                          RUN_START(_RamfuncsRunStart),
                          RUN_SIZE(_RamfuncsRunSize),
                          RUN_END(_RamfuncsRunEnd),
                          PAGE = 0, ALIGN(8)
       #endif
    #endif
    
    
       /* The following section definition are for SDFM examples */
       Filter1_RegsFile : > RAMGS2_7,	PAGE = 1, fill=0x1111
       Filter2_RegsFile : > RAMGS2_7,	PAGE = 1, fill=0x2222
       Filter3_RegsFile : > RAMGS2_7,	PAGE = 1, fill=0x3333
       Filter4_RegsFile : > RAMGS2_7,	PAGE = 1, fill=0x4444
    
    
    C2ToC1RAM : > CPU2TOCPU1RAM, PAGE = 1
    C1ToC2RAM : > CPU1TOCPU2RAM, PAGE = 1
    
    #ifdef CLA_C
       /* CLA C compiler sections */
       //
       // Must be allocated to memory the CLA has write access to
    
       CLAscratch       :
                         { *.obj(CLAscratch)
                         . += CLA_SCRATCHPAD_SIZE;
                         *.obj(CLAscratch_end) } >  RAMLS45,  PAGE = 1
    
       .scratchpad      : > RAMLS45,       PAGE = 1
       .bss_cla		    : > RAMLS45,       PAGE = 1
       .const_cla       : > RAMLS45,       PAGE = 1
    
    
    #endif //CLA_C
    }
    
    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
    

    附上CMD文件

  • 回答问题3:您的意思是不是将  .const_cla       : > RAMLS45,       PAGE = 1 修改如下:

    对的,CLA CONST 要加载到flash并复制到 RAM。 请确保添加 memcpy 函数以将内容从flash复制到 RAM。

  • 好的,我试一下看看