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.

TM4C123GH6PM: Flash Memory

Part Number: TM4C123GH6PM

Tool/software:

Hello Everyone,

I am new to programming flash memory and need some help.

I have some user settings that need to be saved in non-volatile memory.

I have found an example here,

https://www.youtube.com/watch?v=coztn7F4jbM

Which state that you can "program anywhere" as long as you don't overwrite where the program is stored.

After reading the datasheet I get more confused as it doesn't discuss anything referenced in the video above. There doesn't appear to be a safe region of memory to program except the User Registers which are too small of the user settings I need to store. 

Does anyone have any advice on how to get started?

Thanks,

Allan

  • Hi Allan,

      Yes, you could program your user data to the flash but you need to be extremely careful not to overwrite the existing program code that is stored on the flash. For example, there are 256kB of flash on TM4C123GH6PM. Let's say you know for sure your firmware will never exceed 128kB then you could use the upper 128kB to store your user's data during runtime. The question to ask is how much data do you need to store? Why wouldn't you store your runtime user data on the EEprom if you only have a few data to store? Unless you need to save a lot of data, there is a 2kB EEprom on TM4C123 MCU. You could save your runtime user data on EEprom. Programming EEprom is fairly simple. Anything that the youtube example you were watching can be done using the EEprom. Refer to the below example which you can also find in the Peripheral Driver User's Guide. 

    = EEPROMInit();
    //
    // Check if the EEPROM Initialization returned an error
    // and inform the application
    //
    if(ui32EEPROMInit != EEPROM_INIT_OK)
    {
    while(1)
    {
    }
    }
    //
    // Program some data into the EEPROM at address 0x400.
    //
    pui32Data[0] = 0x12345678;
    pui32Data[1] = 0x56789abc;
    EEPROMProgram(pui32Data, 0x400, sizeof(pui32Data));
    //
    // Read it back.
    //
    EEPROMRead(pui32Read, 0x400, sizeof(pui32Read));