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/TMS570LC4357: Flash API Programming issue - RWAIT

Part Number: TMS570LC4357

Tool/software: Code Composer Studio

I am trying to program a flash memory location of Bank1 from Bank 0 of TMS57LC4357 and running the flash library from SRAM.
As per spnu501 after programming command, Observed the value 0x1010 from FAPI_GET_FSM_STATUS which means that PGV bit and CSTAT bit are set.
In our application the HCLK=90MHz (GCLK=180 MHz), As per data sheet RWAIT needs to be set to '2'(not working) and we tried configuring the RWAIT to different values 1- 8 and observed below:
1. RWAIT values set to 1-6 - 0x1010 from FAPI_GET_FSM_STATUS and not programmed the data at flash address .
2. RWAIT value set to 7-8 - 0x1010 from FAPI_GET_FSM_STATUS and programmed few bytes correctly at flash address. but not completely.
I have enabled Fapi_enableAutoEccCalculation before flash initialization. PFB my flash programming code .

Bool flash_api_test(void)
{
    Uint32 address = 0;

    while( (Fapi_enableAutoEccCalculation()) != Fapi_Status_Success);
    
    Fapi_StatusType f_initialize = Fapi_initializeFlashBanks(90);
    Bool init_success = (Fapi_Status_Success == f_initialize);
    
    Fapi_StatusType f_active1 = Fapi_setActiveFlashBank(Fapi_FlashBank1);
    Bool active_success1 = (Fapi_Status_Success == f_active1);
    Fapi_StatusType f_enable1 = Fapi_enableMainBankSectors(0xFFFF);
    Bool enable_success1 = (Fapi_Status_Success == f_enable1);
    address = 0x003C0000;
   
    Fapi_StatusType status = Fapi_checkFsmForReady();
    for (status = Fapi_checkFsmForReady();
          status != Fapi_Status_FsmReady;
          status = Fapi_checkFsmForReady())
    {

    }

    Fapi_enableAutoEccCalculation();

    Fapi_StatusType f_erase_status = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,
                                     (Uint32*)(address));
    Bool pgm_success1 = (Fapi_Status_Success == f_erase_status);
    Bool pgm_success2;
    Fapi_StatusType status1 = Fapi_checkFsmForReady();
    for (status1 = Fapi_checkFsmForReady();
            status1 != Fapi_Status_FsmReady;
            status1 = Fapi_checkFsmForReady())
    {

    }
    pgm_success1 = (pgm_success1 && (FAPI_GET_FSM_STATUS == 0ul));
    
    if(pgm_success1)
    {        
        Fapi_enableAutoEccCalculation();
        Uint64 data = 0x3132333435463738ULL;

        Fapi_StatusType f_program_status = Fapi_issueProgrammingCommand( (Uint32 *)( address ),
                                                      (Uint8 *)( &data ),
                                                            sizeof(data),
                                                                       0,
                                                                       0,
                                                 Fapi_AutoEccGeneration );
        pgm_success2 = (Fapi_Status_Success == f_program_status);
        Fapi_StatusType status3 = Fapi_checkFsmForReady();
        for (status3 = Fapi_checkFsmForReady();
            status3 != Fapi_Status_FsmReady;
            status3 = Fapi_checkFsmForReady())
        {

        }
        pgm_success2 = (pgm_success2 && (FAPI_GET_FSM_STATUS == 0ul));
     }
        
    return pgm_success2;
}

Requesting you to please help me out in above issue in Flash programming.

  • Hello,

    The function Fapi_enableAutoEccCalculation() is enable the Auto generation of ECC and used for users who wants to write their own programming functions. The function Fapi_issueProgrammingCommand() will automatically enable the ECC auto generation if Fapi_AutoEccGeneration is enabled as the programming mode. So you don't have to call Fapi_enableAutoEccCalculation() in your code.

    Did you get the error after sector erase or after the data writing?

  • Thank you Wang for quick reply. The error 0x1010 from FAPI_GET_FSM_STATUS is getting after data writing only. Also, Initially I tried without calling Fapi_enableAutoEccCalculation() and observed the same error. As per my application configuration, HCLK=90MHz (GCLK=180 MHz), RWAIT needs to be Set to 2 which is not working. But, with RWAIT set to 8, able to see some data is programmed but with some few bits are getting flipped. Requesting you to please provide your inputs over this behavior as well.

    In addition to above, with HCLK=150MHz (GCLK=300MHz) Fapi_initializeFlashBanks(150) returns "Fapi_Error_InvalidHclkValue". The library, we are using for TMS570LC4357 is F021_API_CortexR4_BE_L2FMC.lib. Please provide your inputs over HCLK issue as well.

    Thank you, Baba.

  • Hello,

    Please try the CAN bootloader example for TMS570LC43x. This example was tested on TI HDK.

  • Hello,

    There is no issue in erase and program of flash happening successfully with HCLK=90MHz (GCLK=180 MHz), RWAIT set to 3 as per datasheet.

    The issue is now with HCLK=150MHz (GCLK=300MHz) Fapi_initializeFlashBanks(150) returns "Fapi_Error_InvalidHclkValue". The library, we are using for TMS570LC4357 is F021_API_CortexR4_BE_L2FMC.lib. Please provide your inputs over HCLK issue.

    Thank you, Baba.

  • Hello,

    Actually to program flash bank 1, you don't need to execute flash APIs from RAM.

  • Hi, Okay! Does it impact the flash initialize banks with HCLK = 150 MHz (GCLK = 300Mhz) which is returning invalid HCLK error?

    Thank you,

    Baba.

  • Hello,

    The flash is clocked by HCLK and is limited to maximum 150 MHz. It should be fine to use 150MHz if RWAIT=3.