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.

Compiler/TMS320F28379D: EEPROM_EMULATION-TMS320F28379D

Part Number: TMS320F28379D


Tool/software: TI C/C++ Compiler

Hi,

        To implement the EEPROM emulation in tms320f28379d referred the sprab69 , which "function "differentiate  EEPROM Emulation from on-chip Flash writing ... when i am looking  EEPROM Emulation and Flash codes looks  both are same . Can you give me small introduction about how  EEPROM Emulation functions differs from on-chip Flash programming .


Thanks in advance .
 

Thanks & Regards,

Rani

  • Hi, 

    The link you referred (https://www.ti.com/lit/pdf/sprab69) already provide the details . Can you be more specific on your question? 

    In general, EEPROM emulation involves using the Flash APIs to implement EERPOM characteristics( emulate a way to erase a particular byte which is not feasible in Flash) . In Flash, a entire sector has to be erased.

    Best Regards

    siddharth  

  • Siddharth,

       Thanks for the support . How  can differentiate doing the code for " EEPROM Emulation  and FLASH Programming". Because all the flash sector will be applicable for the EEPROM emulation as well as FLASH programming.

               To explain my doubt taking GPIO pins , GPIO pins are having multiplexed functions if i want to set pin as

                output , using API "  (GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT)" , 

                Input  means (GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_IN);

     

    I think so here , there is so specific function to initiate the EEPROM emulation method . How to specified the processor need to do perform EEPROM emulation method(byte by byte erase/program /read) in specified sector not an FLASH programming ?.

    Thanks in advance .

    Thanks & Regards,

    Rani

  • Hi , 

    You need to decide/allocate which sectors in the Flash will be used for EEPROM emulation.  There can be address check done before calling EEPROM emulation APIs  to make sure that only the specified sectors are used.

    Best Regards

    Siddharth

  • Siddharth,

             EEPROM emulation APIs  means you are mention about EEPROM write(), read() ,erase()  function or  new one .


    My Doubt is ,

       1.How to specify read/write/erase functions will be byte by byte (eeprom emulation method) or full sector(Flash programming)

      2. How to split page and bank , its user defined or default (bank 8x page8).

      3.how to decide  page size .

          To find page size referred the "EEPROM Emulation With the TMS320F28xxx DSCs" document

          4K x 16 size Flash sector can be divided into 32 pages, each having a size of 128 x 16. That makes each Page equivalent to a 256 x 8 Bytes EEPROM.      
        

           when i come to  www-s.ti.com/sc/techlit/sprab69.zip reference code given page size is 64Word.Example code is applicable for various    controller(f2806,f2809etc)  its sectors sizes are varies from one another. How to find page size ?

  • Ajay,

    Please note that we don't have an EEPROM emulation driver/example for F2837xD devices.  The SPRAB69 guide that you are referring is a good start to understand on how to implement EEPROM emulation using flash.  However, the flash API functions used in that guide are not applicable for F2837xD.  Flash API for F2837xD is different since the flash wrapper and the features are different for this device.  You can still use the guide to learn the EEPROM emulation using flash and implement your own EEPROM driver for F2837xD using it's flash API. 

    Two things that you need to note when implementing EEPROM driver for F2837xD after understanding the concept from above guide:

    1. Flash API is different - Please refer to https://www.ti.com/lit/ug/spnu629/spnu629.pdf . You need to use this API functions to implement your EEPROM write(), erase() etc.

    2. F2837xD Flash has ECC.  For every 64-bits of main array, there are 8-bits of ECC.  Hence, you need to program at least 64-bits at-a-time even if you are trying to update a variable of size 16-bits.  

    Regarding your questions:  

    1. How to specify read/write/erase functions will be byte by byte (eeprom emulation method) or full sector(Flash programming):

    Flash erase always happens for the entire sector.  During EEPROM emulation, when you want to update a variable, the target flash location for the variable is not erased every time you want to update the variable.  The new value that you want to program for the variable will be saved in the next flash location and this new location will be treated as the latest address for the reads.  Sector will be erased only when the entire sector is used up to update the variable. 

    When it comes to program or read, you can specify the length as mentioned in the guide.

    2 and 3. How to split page and bank, its user defined or default (bank 8x page8)? How to decide  page size: It is user defined and not default.

    I see that www-s.ti.com/sc/techlit/sprab69.zip is broken - I will ask our web team to fix this.

    Thanks and regards,

    Vamsi

  • Vamsi,

        

    When i writing on flash given a starting address of sector , its writes data sector memory .

      

    But  Given the middle of the Address to write on sector  its not works .

    Question:

    1. Can  I overwrite my data on same location ?  

            ex. A=10( address:0x8000) , need to write the value of  variable " A " in same address(0x8000) every time variable gets change.

    2.Can I  access  (write/Read) the  data by address( sending particular address) based?

        Ex: B =Read( 0x8000);

              B=Write(0x82000);

    3.how can i find the page of the next location to write ?

    4. Is this possible to continue from the last variable is stored  address?

     

    Thanks & Regards,

    Rani

  • Vamsi,

          One more question can I use "Fapi_AutoEccGeneration" ?

  • Rani,

    Regarding the program issue: What is the FMSTAT value after the operation? Also, what is the error returned from flash program function?

    1.  Regarding "Can I overwrite my data on same location?":

    You can program a location again if you are going to change only a 1 to 0. 

    But, you need to take couple of things in to consideration:

    a) F2837xD flash has ECC.  Hence, even if you are changing a 1 to 0 in flash, corresponding ECC may change from 0 to 1 -> Which is not allowed for program operation.  Meaning, once you program ECC for a given flash location, you can not reprogram that location without an erase.  

    b) Take a look at errata advisory: Flash: Minimum Programming Word Size. 

    2. You can read the flash by using address.  For writes, you need to use flash API.

    3 and 4. Did you go through the EEPROM guide and EEPROM driver source code?  They should give you an idea on these.  

    Thanks and regards,
    Vamsi

  • Ajay,

    Fapi_AutoEccGeneration mode is used when you want the flash API to calculate and program the ECC automatically for a given 64-bit main array data (64-bit aligned).

    This is the mode that you can use to program ECC easily.

    Thanks and regards,

    Vamsi

  • Hi Rani,

    Ajay S said:
    3.how can i find the page of the next location to write ?

    Section 3.2 'Creating EEPROM Sections (Pages) and Page Identification' should help answer your questions about how to structure banks / pages. Note that there is a bank and page status word at the start of each.

    Ajay S said:
    4. Is this possible to continue from the last variable is stored  address?

    Not sure what you mean here. For writing to / reading from the allocated eeprom sections of flash? or something else?

    Best,

    Kevin

  • Vamsi ,

       Status of FMSAT is After  writing  data on sector is 30, But address should in the multiple of 8 only.

    If Address not in the multiple of 8 , not writing on sector and FMSAT is 0.

    I can use the addresses are the multiple of 8 only to write/read the program?

    Thanks & Regards,

    Rani

  • Hi Kevin,

    You are mentioned 3.2 section for bank and page reference , using TMS320F28379D implement the EEPROM Emulation on SECTOR B( Range 0x00082000-0x00083fff) how many page and how many bank i can create it . Is there any rules to find it?.

    Thanks & Regards,

    Rani

  • Vamsi,

             When i tried "EEPROM_ProgramSingleByte(Uint16 data)" function to  write a data from "0x00082000 to 0x00083fff"( Sector B)  but data is not written on Sector in the  consecutive address .For your reference Written data value on memory  picture  is attached .

    Implemented the code bellow for EEPROM_ProgramSingleByte(Uint16 data) function;

    Why its not writing on consecutive address? any mistake in implementing the code ?

    Thanks & Regards,

    Rani

  • Hi Kevin ,

     Can you please explain me how they split 4k x16 into 32 pages . But while implementing the code the use 8bank x 8 pages . so  i have little bit confused in split the bank and page .

    Page and Bank used in Implementing the code for f28xxx, Page =8, Bank=8.

     

    For 4k X16 split-ed page as 32 mentioned in section 3.1 , in program they  implemented by using page 8 x bank 8 .

    Thanks & Regards,

    Rani

  • Rani,

    There's no 'rule' on how you split up the bank/page since you're emulating an eeprom, not using an actual external eeprom with pre-configured pages/banks. You can split it however you want.

    The example software seems to do 64 word (128 byte) + 1 status word per page. Each bank still has 8 pages as the app note describes. The 128 x16 words (256 x8  bytes) per page was just used as an example in the app note I suppose.

    Best,

    Kevin

  • Rani,

    Regarding your question "I can use the addresses are the multiple of 8 only to write/read the program?":

    Please search for "How many bits can be programmed at a time using Fapi_issueProgrammingCommand()?" in the FAQ post at https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/951668

    Thanks and regards,
    Vamsi

  • Vamsi,

     Now I can write/Read the Flash Sector memory by EEPROM Emulation Method .But after the power  off my values are get erased not retained on Sector .

    To check values are retained or not done the blink code based on read value .  After the power off  its not works ,so my values are get erased .

    Why its gets erased? Please provide an solution to solve this problem..

    Readbuffer[0] has eight before power off.

    Code i have done for check the value retain on sector or not

    Thanks & Regards,

    Rani

  • Rani,

    Glad you are able to program now.

    Regarding content getting erased:

    • Please check your code to make sure that erase is not included somewhere.
    • Also, check if you are erasing it as part of project launch/load.
    • The read_buffer variable you are showing is in RAM - hope you are not reading it after power cycle and before reading the flash.  Please check.

    Thanks and regards,

    Vamsi

  • Vamsi,

             Thank you for your kind words.

    Regarding content getting erased:

        Please check your code to make sure that erase is not included somewhere

                     Still now i am not added erase function in my code implementation.

      Also, check if you are erasing it as part of project launch/load

                     Below the function are used on launch /load code

              

       After reading the memory only i am checking the read buffer



     

     Regarding my side:

         Getting the warning because of Copy the Flash API functions to SARAM


          MemCopy(&Flash28_API_LoadStart, &Flash28_API_LoadEnd, &Flash28_API_RunStart);



     In cmd file i have added like below



    Warnings are

          No Matching Section
         #10087-D LOAD placement ignored for "Flash28_API":  object is placed as part of "GROUP_1" 
         #10082-D placement ignored for "Flash28_API":  object is placed as part of "GROUP_1"   


    Checked the all the function , erase function is not present .wonder how Flash B(0x82000) sector get erased after reset/ power off...

    Before power off /reset my values are written on that.

    I am not sure the way  of  creating .cmd file are correct or not .please give me suggestion how to do it properly .

    Thanks & Regards,

    Rani

  • Rani,

    Regarding erase: After power cycle, when you again load your code in to CCS, it erases the flash and loads your code to flash.  I think it is getting erased during this process.  You can control which sectors you want CCS to erase when you load the code in flash. Go to CCS debug view -> Tools -> On-chip Flash.  In the On-chip Flash GUI, you will see erase settings.  Instead of the default setting that erases entire flash, you can chose the option that erases the necessary sectors -> This will erase only the sectors where you code is going to be programmed (this should not collide with the sectors that you program using flash API in your application).

    Regarding the linker warnings: In your linker command file snapshot that you posted above, I see flash API is included correctly in line # 156.  Why are you including API library again in lines 143 to 153?  You can remove it.

    Thanks and regards,

    Vamsi  

  • Vamsi,

       After changing  the Flash setting i can assure that my data are retain on Flash Sector B . While loading its not getting erased , values are retained on that . But when i make it reset or plugin /plugout of  USB cable its works .  Again if i am load the code i can see value are retain on memory.

    First time loaded the value , 2nd time just read the data from memory and making LED blink its works fine ....

    But Make it RESET/ After power cycle its not works(LED is not blinking) ....

    Thanks & Regards,

    Rani

  • Rani,

    Glad to hear that the data is retained now.

    Regarding reset: You need to check the boot pin config - is it set for flash boot or not?

    Thanks and regards,
    Vamsi

  • Vamsi,

        In my .cmd file begin is pointed to "boot to SARAM"... So here i need to change address ... is this correct ?

    Thanks & Regards,

    Rani

  • Rani,

    In your linker cmd snap, I see that BEGIN is defined as the flash entry point.  Hence, you don't need to change that.

    Please take a look at this and see if anything is applicable:

    Thanks and regards,
    Vamsi

  • Vamsi,

          When upload RUN->LOAD , or given RESET/ Power off  its not working...

    Upload  by the DEBUG option its works fine .

    Debug Configuration Setting

     

    Code:


    //###########################################################################
    //
    // Included Files
    //

    #include "F28x_Project.h"
    #include <string.h>
    #include "flash_programming_c28.h" // Flash API example header file
    #include "F021_F2837xD_C28x.h"
    #include"EEPROM.h"
    #include"MemCopy.h"
    #include"stdio.h"

    //
    // Defines
    //
    #define  WORDS_IN_FLASH_BUFFER    0xFF  // Programming data buffer, words

    #ifdef __TI_COMPILER_VERSION__
        #if __TI_COMPILER_VERSION__ >= 15009000
            #define ramFuncSection ".TI.ramfunc"
        #else
            #define ramFuncSection "ramfuncs"
        #endif
    #endif
    //
    // Pragma
    //
     #pragma CODE_SECTION(EEPROM_Erase,"ramfuncs");
     #pragma CODE_SECTION(EEPROM_Write,"ramfuncs");
     #pragma CODE_SECTION(EEPROM_UpdateBankStatus,"ramfuncs");
     #pragma CODE_SECTION(EEPROM_UpdatePageStatus,"ramfuncs");
     #pragma CODE_SECTION(EEPROM_ProgramSingleByte,"ramfuncs");
     #pragma DATA_SECTION(Read_Buffer,"BufferDataSection");

    //
    // LED
    //
      #define BLINKY_LED_GPIO    31

    //
    // Globals
    //

    uint16_t data;
    bool flag;
    int Read_Buffer[64]={0};


    //
    // Function Prototype
    //
    void Example_Error(Fapi_StatusType status);
    void Example_Done(void);
    //
    // Main
    //
    void main(void)
       {

        InitSysCtrl();
        InitGpio();  // Skipped for this example
        GPIO_SetupPinMux(BLINKY_LED_GPIO, GPIO_MUX_CPU1, 0);
        GPIO_SetupPinOptions(BLINKY_LED_GPIO, GPIO_OUTPUT, GPIO_PUSHPULL);

        InitPieCtrl();
        IER = 0x0000;
        IFR = 0x0000;
        InitPieVectTable();
       //memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
        MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
        initeeprom();
        //  Step 5. User specific code:

        // Copy the Flash API functions to SARAM

        MemCopy(&Flash28_API_LoadStart, &Flash28_API_LoadEnd, &Flash28_API_RunStart);
        SeizeFlashPump();


    //
    // Jump to RAM and call the Flash API functions
    //
          int j=0;
       // EEPROM_GetSinglePointer(1);
           data = 1;
           RESET_BANK_POINTER;     // Reset Bank Pointer to enable search for current Bank
           RESET_PAGE_POINTER;     // Reset Page Pointer to enable search for current Page
              //   EEPROM_ProgramSingleByte(data);
           flag=1;

        while(1)
        {




            if(flag==1&& (*Bank_Pointer)==0xFFFF) // after power up  set flag=1
            {
            EEPROM_Write(7);
            for(j=0;j<10;j++);
            }
            if(flag==1)
            {
            Read_Buffer[0]=EEPROM_Read();   // reading flash
           flag=0;
           ReleaseFlashPump();
            }
               if(Read_Buffer[0]==7)
           {


                   GPIO_WritePin(BLINKY_LED_GPIO, 0);
                   DELAY_US(1000*500);
                   GPIO_WritePin(BLINKY_LED_GPIO, 1);
                   DELAY_US(1000*500);
           }


        }


    }





    //
    // Example_Done - For this example, once we are done just stop here
    //
    #pragma CODE_SECTION(Example_Done,ramFuncSection);
    void Example_Done(void)
    {
        __asm("    ESTOP0");
    }

    //
    // End of file
    //

    Thanks & Regards,

    Rani

  • Rani,

    Since you are able to program fine now, I would suggest you to open a new post for this question so that we can assign it to the corresponding expert to help you further.

    Thanks and regards,
    Vamsi

  • Vamsi ,

             Thank you ...Sure .

    Thanks & Regards,

    Rani