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/TMS320F280041: Flash reading issue

Part Number: TMS320F280041
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello,

I want to read flash in between running of C Code.

I can erase the flash by Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32 *)0x087000); function of flash api.

I can write the flash by Fapi_issueProgrammingCommand((uint32 *)u32Index, au16DataBuffer, 8,0, 0, Fapi_DataOnly); function of flash api.

is there any similar function like above to read flash address and store data in data buffer.

fapi_domarginread (); is there but it is not supported in 280041 controller.

Actually I don t have EPROM In my hardware so i wants to use half sector of flash to store calibration parameter.

Please suggest any sample code for this purpose.

Please suggest any alternative for this.

Regards,

Bharat

  • Hi Bharat,

    Flash reads are no different from RAM reads.  You can implement flash reads just like you do RAM reads.

    Regarding EEPROM emulation on this device: Please take a look at 

    Thanks and regards,
    Vamsi

  • Hello,

    The written code is as per below.

    if(flag.erase)
    {
    Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 100);
    Fapi_setActiveFlashBank(Fapi_FlashBank0);
    Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32 *)0x087000);
    while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    flag.erase = 0;
    }

    if(flag.programe)
    {
    EALLOW;
    //uint32 *DataBuffer32 = (uint32 *)au16DataBuffer;

    oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 100);
    oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);

    for(u32Index = 0x087000; (u32Index < 0x087007) &&
    (oReturnCheck == Fapi_Status_Success); u32Index+=8)
    {
    Fapi_issueProgrammingCommand((uint32 *)u32Index, au16DataBuffer, 8,
    0, 0, Fapi_DataOnly);

    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    }


    EDIS;

    oFlashStatus = Fapi_getFsmStatus();

    //Fapi_doVerify((uint32 *)u32Index, 4, DataBuffer32, &f_api_flash_status_word);

    flag.programe = 0;

    }

    if(flag.read)
    {

    Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 100);
    Fapi_setActiveFlashBank(Fapi_FlashBank0);
    DataBuffer32 = *(uint16*)0x087001;
    flag.read = 0;
    }

    When i am trying read flash using pointer then it will trigger NMI ISR and controller goes in to halt mode.

    Please check the code and help to resolve the problem.

    Regards,

    Bharat

  • Bharat,

    NMI ISR is occurring due to ECC errors.  

    When calling the program function, you are using Fapi_DataOnly mode.  Instead, you can use Fapi_AutoEccGeneration mode - this calculates and programs the ECC for the flash data.

    Please take a look at that flash programming example in C2000Ware.

    Flash API usage FAQ: e2e.ti.com/.../951668

    Flash ECC FAQ: https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/951658 

    Flash API guide: https://www.ti.com/lit/pdf/spnu628 

    Thanks and regards,

    Vamsi

  • Hello ,

    By using Fapi_AutoEccGeneration in program function resolve my issue.

    But Can you please give a clarification how this will effect on flash program function.

    Regads,

    Bharat  

  • Bharat,

    As I explained in the flash API guide and the FAQs, Fapi_AutoEccGeneration mode requires you to program either 64-bits (aligned on 64-bit boundary) or 128-bits (aligned on 64-bit boundary) at a time.  

    Did you take a look at the flash programming example in C2000ware?  It shows the usage of this mode.  Please check and let me know if you have any questions.

    Thanks and regards,
    Vamsi

  • Thank You very much for your support.