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.

TMS320F280049: Use CLA task 1 more than 2K words

Part Number: TMS320F280049

Dear Champs,

I am asking this for our customer.

The customers uses F280049 Launchpad for testing their own codes.

When their task1 code size is smaller than 2K works, there is no problem to run it on CCS or in standalone.

But when they wrote more codes and increased the task1 code size to larger than 2K words (about 3K words), they found something weird.

They could run it well on CCS with flash boot emulation (i.e. Reset CPU->Script/EMU flash->Run). He could also debug in CLA on CCS and saw GPIO toggling, too.

There was no special warning on the compiler.

But when they tried to run it in standalone without CCS/JTAG, it seemed nothing (C28/CLA) could run because the GPIO toggling in CLA failed.....

They use LS4+LS5 for CLA program memory and moved codes from flash to RAM accordingly.

Why the codes can be run on CCS well with flash emulation boot, but it failed in standalone?

Do you have any suggestion for us to debug?

We suspect the .cmd file is wrong, but we have not found it so far.

I can send you their .cmd and .map offline.

In the .cmd

/*LS4/LS5 RAM(4k)*/
RAMLS_CLA_PROG : origin = 0x00A000, length = 0x001000

Cla1Prog :

LOAD = FLASH_BANK1_CLA_PROG,
RUN = RAMLS_CLA_PROG ,
LOAD_START(_Cla1funcsLoadStart),
RUN_START(_Cla1funcsRunStart),
LOAD_SIZE(_Cla1funcsLoadSize),
PAGE = 0, ALIGN(4)

In C codes,

memcpy(&Cla1funcsRunStart, &Cla1funcsLoadStart, (Uint32)&Cla1funcsLoadSize);

MemCfg_setCLAMemType(MEMCFG_SECT_LS4, MEMCFG_CLA_MEM_PROGRAM);
MemCfg_setCLAMemType(MEMCFG_SECT_LS5, MEMCFG_CLA_MEM_PROGRAM);
MemCfg_setCLAMemType(MEMCFG_SECT_LS0, MEMCFG_CLA_MEM_DATA);
MemCfg_setCLAMemType(MEMCFG_SECT_LS1, MEMCFG_CLA_MEM_DATA);
MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS4, MEMCFG_LSRAMMASTER_CPU_CLA1);
MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS5, MEMCFG_LSRAMMASTER_CPU_CLA1);
MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS0, MEMCFG_LSRAMMASTER_CPU_CLA1);
MemCfg_setLSRAMMasterSel(MEMCFG_SECT_LS1, MEMCFG_LSRAMMASTER_CPU_CLA1);

In the .map

Cla1Prog 0 0009e000 00000be6 RUN ADDR = 0000a000
0009e000 000008ba cla_task.obj (Cla1Prog:_Cla1Task1)
0009e8ba 000002a2 cla_task.obj (Cla1Prog:_Cla1Task2)
0009eb5c 0000008a cla_task.obj (Cla1Prog:_Cla1Task8)

OR is there any restriction or condition about this?

Wayne Huang

  • Wayne Huang said:

    When their task1 code size is smaller than 2K works, there is no problem to run it on CCS or in standalone.

    But when they wrote more codes and increased the task1 code size to larger than 2K words (about 3K words), they found something weird.

    They could run it well on CCS with flash boot emulation (i.e. Reset CPU->Script/EMU flash->Run). He could also debug in CLA on CCS and saw GPIO toggling, too.

    Wayne,  Your customer will need to look for more clues and debug:

    1. Is their main C28x application running?  Or is it only the CLA code that is not running? If they can't tell about the C28x, add an indication that lets them know if it is running. 
    2. Is the device getting reset?  Monitor the reset line and see if it toggles. - my thought is it maybe the watchdog timer in stand-alone starts timing out if the copy of CLA code takes too long.
    3. If they power-up stand alone, then connect CCS and only load symbols (don't debug the project which will load the code, only load symbols) then do a reset + run does the code work?   If not, then maybe something isn't being copied to RAM correctly but the debugger initializes it.  Check the memory map for initialized sections in RAM (instead of flash).

    I don't see anything incorrect in the memory allocation you listed. 

    Lori

  • Dear Lori,

    Now, the user seems to identify where caused the problem, but does not know the reason.

    They found the issue disappeared after they changed the order of 

     InitFlash();

    They use GPIO toggling to trace code and finally found below:

    // Issue occurred if InitFlash() was located after CLA memory copy. They did find there was nXRS periodically reset, but they confirmed the watchdog was reset by looking into WDDIS on CCS Watch Window.

    MW_RUNTIME_FLASHLOAD = 1

    CLA_BLOCK_INCLUDED   = 1

     

    void c2000_flash_init(void)

    {

    #if MW_RUNTIME_FLASHLOAD

    /* Copy InitFlash function code and Flash setup code to RAM */

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

    memcpy(&MW_RamfuncsRunStart, &MW_RamfuncsLoadStart, (Uint32)&MW_RamfuncsLoadSize);

    #ifdef CLA_BLOCK_INCLUDED

      memcpy(&Cla1funcsRunStart, &Cla1funcsLoadStart, (Uint32)&Cla1funcsLoadSize);

      /*memcpy(&Cla1mathTablesRunStart, &Cla1mathTablesLoadStart, (Uint32)&Cla1mathTablesLoadSize); */

    #endif

    /* Call Flash Initialization to setup flash waitstates

    This function must reside in RAM */

    InitFlash();

     

    #endif

    }

     

    // Issue was gone after they located InitFlash() before CLA memory copy

    void c2000_flash_init(void)

    {

    #if MW_RUNTIME_FLASHLOAD

    /* Copy InitFlash function code and Flash setup code to RAM */

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

    memcpy(&MW_RamfuncsRunStart, &MW_RamfuncsLoadStart, (Uint32)&MW_RamfuncsLoadSize);

    #endif

    /* Call Flash Initialization to setup flash waitstates

    This function must reside in RAM */

    InitFlash();

    #ifdef CLA_BLOCK_INCLUDED

      memcpy(&Cla1funcsRunStart, &Cla1funcsLoadStart, (Uint32)&Cla1funcsLoadSize);

      /*memcpy(&Cla1mathTablesRunStart, &Cla1mathTablesLoadStart, (Uint32)&Cla1mathTablesLoadSize); */

    #endif

    }

    Do you have any comment how to explain the above?

    Wayne Huang

  • Wayne,

    • The watchdog is likely not disabled when they are running stand alone while it is disabled in the code composer studio gel file.  To edit the gel file go to  Tools -> Debugger Options -> Misc/Other Options.  On the left, select "GEL Files" and then double click on the f280049c.gel.

    As supplied, within the OnReset() function, CCS disables the watchdog.  This is why the reset does not occur when the debugger is connected:

    OnReset(int nErrorCode)
    {
    
        *(int *)0x5FB00 = 0; 		/* Disable Flash ECC */
        *(int *)0x7029 = 0x68;  		/* Disable WD */
        
        *(unsigned long *)0x7060 = 0x0001;  /* Enable NMI */
        
        SetupDCSM();  						/* Initialize DCSM */

    • InitFlash changes the waitstates of the flash accesses making them faster and resulting in a fast copy of content from Flash to RAM.  This is why the timeout does not occur if InitFlash is performed first.

    Regards

    Lori