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.

TMS320F28020: Writing app data to Flash like an EEPROM

Part Number: TMS320F28020
Other Parts Discussed in Thread: C2000WARE,

Hi All,

I'd like to use on-board flash to store a few application variables, so they are available to restore after a power cycle.

This project's alpha code has been delivered to the client for eval, but this memory storage functionality will be needed before beta release.

I've done this on the F28069 & F28379, but I'm not finding any documentation or example code for the F2802x series.  Reference to the F2802x is conspicuously absent from SPRAB69.  Can I assume using the same API will work?

If the same F28xxx code will work, I'll follow up with questions about bare minimum requirements to add this functionality to my mostly complete project.  A flash sector has been reserved for this, but RAM is limited.

Thanks,
robin

  • Robin,

    From a Flash technology the F28020 device is the same as the F28069 so I see no technical reason this should not work on this device.  Let's see what we run into, but I suspect the small amount of RAM may be why this device is not listed in that app note.  I may need to do a bit more research to see what memory shuffling we might need to do.

    Let me know what you see when trying to add/fit this in your device.

    Best,

    Matthew

  • Hi Matthew,

    I followed the "Flash2802x_API_Quickstart.pdf" guide I found here: C:\ti\C2000Ware_4_01_00_00\libraries\flash_api\f2802x\docs.

    I'm calling Flash_Program() in the main() idle loop as follows:

            case SOS:   //h Easter egg, not documented, SOS blink on LED
            {
                Uint16  Status;
                Uint32 Length = 4;
                FLASH_ST ProgStatus;
    
                GPIO_toggle(myGpio, RED_LED);///
                Write_Buffer_calVals[0] = 0xdead;
                Write_Buffer_calVals[1] = 0xbeef;
    
                EALLOW;
                Flash_CPUScaleFactor = SCALE_FACTOR;
                Flash_CallbackPtr = NULL;
                EDIS;
    
                calVals_Pointer = (Uint32 *)0x3F6000;   // Sector C
    
                EALLOW;
                DINT;
                EDIS;
    
                Status = Flash_Program((Uint16 *)calVals_Pointer,(Uint16 *)Write_Buffer_calVals,Length,&ProgStatus);
    
                EALLOW;
                EINT;
                EDIS;
    
                calVals_Pointer = (Uint32 *)0x3F6000;   // Sector C
                Read_Buffer_calVals[0] = *(calVals_Pointer++);
                Read_Buffer_calVals[1] = *(calVals_Pointer);
    
                out[0]  = (unsigned int)Read_Buffer_calVals[0] >> 0;
                out[1]  = (unsigned int)Read_Buffer_calVals[1] >> 0;
                out[2]  = (unsigned int)Read_Buffer_calVals[0] >> 0;
                out[3]  = (unsigned int)Read_Buffer_calVals[1];
                out[4]  = 0x0a;        // Line feed
                out[5]  = 0x0d;        // Carriage return
                out[6]  = 0x00;        // Null
    
                sciMasterTransmit((const char *)out);
            }
            break;
    

    Watching the disassembly window while stepping through code, As seen here, it appears to be running from flash, not RAM:

    Question #1:

    Since this function (or macro) is part of the flash API library, how do I memcpy() it to RAM?

    When I let the code run, it produces the following source file error:

    I wasn't able to locate the file, "Flash28_Prog.c".

    Question #2:

    Where can I find this file?

    Thanks,
    robin

  • New info:

    I added "2802x_FlashAPI_BootROMSymbols_v2.01.lib" to the project and now flash API functions run from ROM.

  • Robin,

    That was going to be my suggestion, as this saves a significant amount of RAM using the ROM based APIs.  Is there still a pending question at this time?

    Best,

    Matthew

  • Thanks for your help Matthew.

    So, if anyone ever asks again, yes you can use the on-board flash of the TMS320F2820 for nonvolatile storage of application variables.

    Thanks again!

  • Correction: the part in question is:  TMS320F28020

  • Thanks for the follow up Robin, glad this was able to work for your application.

    Best,

    Matthew