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.

TMS320F28377S: Fapi_issueProgrammingCommand program one word at the time

Genius 5910 points
Part Number: TMS320F28377S
Other Parts Discussed in Thread: C2000WARE

I'm trying to program flash. one word at the time and it doesn't work.

I tied this:

         oReturnCheck = Fapi_issueProgrammingCommand((uint32_t *)(address+i),(data+i),
                                                     1,0,0,
                                                     Fapi_AutoEccGeneration);

Only this result in parts that are programmed and parts that are not.

Is it possible to program 1 word at the time and if so how?

Thanks!

note oReturnCheck is alway Fapi_Status_Success

  • Hi,

    Please search for below questions in the Flash API wiki at: http://processors.wiki.ti.com/index.php/C2000_Flash_FAQ#Flash_API_wiki 

    1. How many bits can be programmed at a time using Fapi_issueProgrammingCommand()?

    2. When using Fapi_AutoEccGeneration mode, what is the minimum number of 16-bit words that can be programmed?

    3. When using Fapi_AutoEccGeneration mode, for a given 128-bit aligned memory, can I program lower 64-bits at one time and upper 64-bits at another time?

    4. Why do you have different programming modes for Flash programming function (Fapi_issueProgrammingCommand())?

    In short: You need to program 64-bits at-a-time (on 64-bit aligned address) when using Fapi_AutoEccGeneration mode.

    Please check the "Minimum programming word size" errata advisory - It tells that you can not program less than 64-bits.

    Flash API reference guide link: http://www.ti.com/lit/pdf/spnu630 

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    Ok, thanks I redesigned my data FIFO that the data is 128 bit aligned. But still I have problems programming the flash.

     program  size=1024 words at the time.

    address = 0xc2000

    Data is not 0XFFFF. I checked that.

    Flash is erased.

    My program runs in bank0

    This is the relevant code:

        EALLOW;
        Flash_CfgBank1 ();  // init the flash programming process

        for(i=0;i<size;i+=8)
         {
             oReturnCheck = Fapi_issueProgrammingCommand((uint32_t *)(address+i),(uint16_t *)(data+i),
                                                         8,0,0,
                                                         Fapi_AutoEccGeneration);
             while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
             SysCtl_delay (10);
             if(oReturnCheck != Fapi_Status_Success) return oReturnCheck;

         }
        Flash_DoneBank1 ();


    I the result is always Fapi_Status_Success

    This is the output in flash:

    The next section starts at 0xC2400. That shows also on the picture. That is even shorter. 

     Any suggestion?

    Thanks!

  • Hi,

    Here are some tips for the debug:

    1) Can you confirm the wait-state configuration that you did for Bank1 FMC? And what is the operating frequency?

    2) I understand you mentioned that the sector is erased, but could you issue an erase command before the program loop? Just to make sure ECC space is also erased.

    3) Regarding the success status return: Please search for "If the Fapi_issueProgrammingCommand() function does not wait for the program operation completion, how do we know whether the program operation succeeded or not?" in the Flash API wiki.  

    Please include FMSTAT check to catch any program failure. 

    4) Can you confirm that below functions are called with highlighted parameters before Bank1 Flash operations?

    oReturnCheck = Fapi_initializeAPI(F021_CPU0_W1_BASE_ADDRESS, xxx);

    if(oReturnCheck != Fapi_Status_Success)

    {

    Example_Error(oReturnCheck);

    }

    oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank1);

    if(oReturnCheck != Fapi_Status_Success)

    {

    Example_Error(oReturnCheck);

    }

    5) I am sure you would have given pump access to Bank1 FMC.

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    Thanks for the reply.
    1) set the flash wait state to 0xF. and operating freq is 200Mhz. See code in 4).
    2) The Jtag erase all the memory before the program start.
    But I also before I start programming I erase all FLASH0 till FLASHAB.
    This is the code I use for erasing:
    Flash_CfgBank1 is call before the call.

    Fapi_StatusType Flash_Erasebank (uint32_t address)
    {
    Fapi_StatusType oReturnCheck;
    EALLOW;
    DISABLE_INTERRUPTS;
    oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,(uint32_t *) address);
    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    ENABLE_INTERRUPTS;
    return oReturnCheck;
    }

    3) I think I do that with this line:
    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    4) Before I do a write /erase action I call this functiom:

    Fapi_StatusType Flash_CfgBank1 (void)
    {
    volatile Fapi_StatusType oReturnCheck;
    EALLOW;
    Flash_setWaitstates (FLASH1CTRL_BASE,0x0F);
    Flash_disableCache (FLASH1CTRL_BASE);
    Flash_disableECC (FLASH1ECC_BASE);
    Flash_claimPumpSemaphore (FLASHPUMPSEMAPHORE_BASE,FLASH_BANK1_WRAPPER);
    oReturnCheck = Fapi_initializeAPI(((Fapi_FmcRegistersType *)F021_CPU0_W1_REGISTER_ADDRESS),200);
    if (oReturnCheck != Fapi_Status_Success ) return oReturnCheck
    oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank1);
    if (oReturnCheck != Fapi_Status_Success ) return oReturnCheck
    }

    5) See the code in 4).

    So I'm under the impression I did all the things you suggested.

    Regards,



    Note: This is the code I use for flash programming:

    for(i=0;i<size;i+=8) // size is 1024
    {
    DISABLE_INTERRUPTS;
    Flash_CfgBank1 (); // init the flash programming process
    oReturnCheck = Fapi_issueProgrammingCommand((uint32_t *)(address+i),(data+i),
    8,0,0,
    Fapi_AutoEccGeneration);
    while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy); // Waiting for FSM flag
    if(oReturnCheck != Fapi_Status_Success) return oReturnCheck;
    Flash_DoneBank1 ();
    ENABLE_INTERRUPTS;
    }
  • Hi,

    1. At 200MHz, a waitstate of 3 is enough. Replace 0xF with 0x3. Datasheet provides the RWAIT configuration info.

    2. Ok. Do you have watchdog enabled? If yes, do you service it regularly as needed?

    3. You should achieve it using Fapi_getFsmStatus(). Please read sections 3.2.7 Fapi_getFsmStatus() and 3.2.3 Fapi_issueProgrammingCommand() in the Flash API guide. And usage of this function is shown in the example provided for section 3.2.3. Also, please take a look at the flash programming example provided in C2000Ware.

    If program operation fails, FMSTAT should tell you why it failed.

    4. Ok.

    5. Ok.

    I see you included Flash_CfgBank1() in the program loop. I would suggest to bring it out of the loop and call once before the program loop.

    Can you run the example provided in C2000Ware and see if that works for you?
    Also, are you using DCSM?

    Thanks and regards,
    Vamsi
  • Hi,

    This was part was missing in my cmd file.
    GROUP
    {
    ramfuncs
    .TI.ramfunc
    { -l C:\ti\C2000Ware_1_00_06_00_Software\libraries\flash_api\f2837xs\lib\F021_API_F2837xS_FPU32.lib }
    // { -l ${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INSTALL_DIR}\libraries\flash_api\f2837xs\lib\F021_API_F2837xS_FPU32.lib }
    }LOAD = FLASHD,
    RUN = RAMLS0,
    LOAD_START(_RamfuncsLoadStart),
    LOAD_SIZE(_RamfuncsLoadSize),
    LOAD_END(_RamfuncsLoadEnd),
    RUN_START(_RamfuncsRunStart),
    RUN_SIZE(_RamfuncsRunSize),
    RUN_END(_RamfuncsRunEnd),
    PAGE = 0, ALIGN(4)

    Can you please tell me how to use relative pads?

    I successful tested flash programming. I still have some issues but I don't think there are related to flash programming.

    Thanks!
  • Hi,

    Glad the example helped.

    I did not understand your question. What do you mean by relative pads?

    Thanks and regards,
    Vamsi
  • Vamsi Gudivada said:
    Hi,

    Glad the example helped.

    I did not understand your question. What do you mean by relative pads?

    Thanks and regards,
    Vamsi

    -l C:\ti\C2000Ware_1_00_06_00_Software\libraries\flash_api\f2837xs\lib\F021_API_F2837xS_FPU32.lib }

    I only get this to work.


      { -l ${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INSTALL_DIR}\libraries\flash_api\f2837xs\lib\F021_API_F2837xS_FPU32.lib }

    And I needs something like? So how do I implement relative paths in the cmd file.

  • Hello

    In your project properties, under C2000 linker, should be able to add the directory to the library search path and then in the linker you just have to put "-l F021_API_F2838xS_FPU32.lib"

    Best regards
    Chris