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: Erase & Program with F021 API

Other Parts Discussed in Thread: TMS570LS3137

Tool/software: Code Composer Studio

Hi,
I try to erase and program data for Flash Memory (TMS570LS3137) with F021 API,
However both operations don't success.

I want to erase and program data to "FlashBank1 Sector0".

My code looks like as follows.

What's the wrong with my code?


// Erase Phase

Fapi_initializeFlashBanks(50);

Fapi_setActiveFlashBank(Fapi_FlashBank1);

Fapi_enableMainBankSectors(Fapi_FlashSector0);

Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t *)0x00180000U);

while(Fapi_Status_FsmBusy == Fapi_checkFsmForReady());


// Program Phase
Fapi_initializeFlashBanks(50);

Fapi_setActiveFlashBank(Fapi_FlashBank1);

Fapi_enableMainBankSectors(Fapi_FlashSector0);

Fapi_issueProgrammingCommand((uint32_t *)0x00180000U,
                             pu8DataBuffer,
                             u8DataBufferSizeInBytes,
                             0,
                             0,
                             Fapi_AutoEccGeneration);

while(Fapi_Status_FsmBusy == Fapi_checkFsmForReady());

  • Hello,

    I am investigating the problem and will get back to you soon. One thing to check, however, is if you have copied the API routines to run from RAM rather than flash or, at least, confirmed that they are not running from the same bank in which you are trying to erase/program?

    have you had a look at this post to see if their solution is helpful? e2e.ti.com/.../1859354
  • have you had an opportunity to review the post e2e.ti.com/.../1859354 to see if this will help with your success?

    Let me if you need any further help. You can also see implementations of similar use of the F021 Flash API in our bootloader examples. App notes for these can be found on the page at this link : TMS570LS3137
  • Hello,

    Can you check the return value for the F021 Flash API functions called in your code?
    If it returns a non-zero value, it indicates that there is a problem with the device configuration/initialization.

    Thanks,
    Siddharth
  • Hello,

    Thanks for Reply.

    I checked the return value for the F021 Flash API functions.
    All returne values is zero(Fapi_Status_Success).

    And I saw and tried  e2e.ti.com/.../1859354, but I could not successed.


    When debug starting, I set the Erase Options to all banks and Sectors.
    However  I see 0x00180000U by memory browser before main function,
    values are "????????".

    Why not 0xFFFF?


    I tried the same operations for Eeprom(Bnak7), it were successed.

    My main function when I used to program data to Eeprom with F021 API functions is as follows.

    /* Program Code for Eeprom */
    
    int main(void)
    {
        /* USER CODE BEGIN (3) */
        uint8_t u8Buf[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
        Fapi_StatusType oReturnCheck = Fapi_Status_Success;
        
        /* Initialize FlashBnaks */
        oReturnCheck = Fapi_initializeFlashBanks(60);
        
        if ((Fapi_Status_Success == oReturnCheck) &&
            (Fapi_Status_FsmBusy != FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY))
        {
            /* Enable Bnak7 */
            oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7);
            
            /* Enable Sector0 in Bnak7 */
            oReturnCheck = Fapi_enableEepromBankSectors(0x01U, 0x00U);
            
            /* Program Data */
            oReturnCheck = Fapi_issueprogrammingCommand((uint32_t *)0xF0200000U,
                                                         u8buf,
                                                         sizeof(u8buf),
                                                         0,
                                                         0,
                                                         Fapi_AutoEccGeneration);
            
            /* Waiting for completed */
            while (Fapi_Status_FsmBusy == Fapi_checkFsmForReady());
        }
        /* USER CODE END */
        
        return 0;
    }


    My main function when I used to program data to FlashRom with F021 API functions is as follows.

    /* Program Code for FlashRom */
    
    int main(void)
    {
        /* USER CODE BEGIN (3) */
        uint8_t u8Buf[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
        Fapi_StatusType oReturnCheck = Fapi_Status_Success;
        
        /* Initialize FlashBnaks */
        oReturnCheck = Fapi_initializeFlashBanks(60);
        
        if ((Fapi_Status_Success == oReturnCheck) &&
            (Fapi_Status_FsmBusy != FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY))
        {
            /* Enable Bnak1 */
            oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank1);
            
            /* Enable Sector0*/
            oReturnCheck = Fapi_enableMainBankSectors(Fapi_FlashSector0);
            
            /* Program Data */
            oReturnCheck = Fapi_issueprogrammingCommand((uint32_t *)0x00180000U,
                                                         u8buf,
                                                         sizeof(u8buf),
                                                         0,
                                                         0,
                                                         Fapi_AutoEccGeneration);
            
            /* Waiting for completed */
            while (Fapi_Status_FsmBusy == Fapi_checkFsmForReady());
        }
        /* USER CODE END */
        
        return 0;
    }


    Why I cannot program data to FlashRom?