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/TMS320F280049: Breakdown to execute Flash_Init() after select optimization level to "0-Register Optimizations"

Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hi 

CCS 7.2.0.00013

Select optimization level to "0-Register Optimizations"

It breakdown to execute Flash_Init() that will jump to an illegal interrupt or prompt an program execution error.

After do breakpoint test step by step, we find it breakdown at Fapi_setActiveFlashBank(Fapi_FlashBank1);

Also, we open "0-Register Optimizations" on another project, no this issue when execute Flash_Init() and Fapi_setActiveFlashBank(Fapi_FlashBank1) function.

What's the reason? Thanks a lot.

  • Daniel,

    Do you execute the Flash API functions and Flash_Init() from RAM or Flash?

    Please check your map file and confirm.

    Thanks and regards,
    Vamsi
  • Hi Vamsi,

    It execute in Flash.

    1. Here is MAP file after enable "0-Register Optimizations"

    2. The same project without enable "0-Register Optimizations"

    3. Another project which include Flash_Init(), even enable "0-Register Optimizations". It's working well .

  • Daniel,

    Note that Flash API (and functions that call Flash API) should be executed from RAM, if you plan to do erase/program operations on both banks.

    If you plan to do erase/program operations on only one bank, then you can execute the Flash API from the other bank (or RAM). I am guessing you want to erase/program Bank1 only, by executing the Flash API from Bank0. Is that correct?

    Also, I noticed that you are using Fapi_FlashBank1 as the parameter for Fapi_setActiveFlashBank(). As mentioned in the F280049 Flash API reference guide, please use Fapi_FlashBank0 only. Fapi_setActiveFlashBank() initializes FMC and both of the Flash banks for erase and program operations. (In F2837xS devices, Fapi_setActiveFlashBank() should be called for each bank since each bank has it's own FMC. In F280049, there is only one FMC). There is no need to execute Fapi_setActiveFlashBank() for each bank in F280049.

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    It's working well now after we change it to the following code. Delect Fapi_setActiveFlashBank(Fapi_FlashBank0);

    Does Fapi_setActiveFlashBank () function running in Flash or RAM now?

    Do we have to move it run in RAM? Thanks.

    #pragma CODE_SECTION(Flash_Init,".TI.ramfunc");

    void Flash_Init(void)

    {

       Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 100);

       // Fapi_setActiveFlashBank(Fapi_FlashBank0);

       Fapi_setActiveFlashBank(Fapi_FlashBank1);

    }

  • Daniel,

    1) As I mentioned previously, if you execute Flash API from RAM, you can do erase/program operations on both Flash banks. 

    If you execute Flash API from Bank0, you can do erase/program operations on Bank1 only.

    If you execute Flash API from Bank1, you can do erase/program operations on Bank0 only.

    Please look at the linker command file used by the Flash programming example in C2000Ware, (C:\ti\c2000\C2000Ware_1_00_06_00\device_support\f28004x\common\cmd\28004x_flash_api_lnk.cmd), you will notice that Flash API library is mapped to Flash for load and RAM for execution.  See below copied from that linker cmd file.

    GROUP
    {
          .TI.ramfunc
           { -l F021_API_F28004x_FPU32.lib}

    } LOAD = FLASH_BANK0_SEC1,
      RUN = RAMLS03,
      LOAD_START(_RamfuncsLoadStart),
      LOAD_SIZE(_RamfuncsLoadSize),
      LOAD_END(_RamfuncsLoadEnd),
      RUN_START(_RamfuncsRunStart),
      RUN_SIZE(_RamfuncsRunSize),
      RUN_END(_RamfuncsRunEnd),
      PAGE = 0, ALIGN(4)

    2) Also, as mentioned in the API guide, please use Fapi_FlashBank0 as the parameter for Fapi_setActiveFlashBank(Fapi_FlashBank0).  

    Thanks and regards,

    Vamsi

  • Excellent reply!