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.

Eeprom or flash TM4c123gh6pmi7

Genius 3300 points
Other Parts Discussed in Thread: TM4C123GH6PM

Hi,

I need to know which one to use flash or eeprom for data storage, since errata says in some condition device may get damaged or eeprom corrupted.
Refer to errate SPMZ849E. I am using rev 7 of TM4C.


A)Flash:
1. Only errata is MEM#14. Flash Write Operation During Execute from Flash may Result in Wrong Instruction
Fetch. I think workaround #1 will work for it in case system is running abobe 40Mhz.

SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); /* slow down system to 40Mhz */
IntMasterDisable();  /* disable main int */
FlashErase(0x10000);
FlashProgram(pui32Data, 0x10000, sizeof(pui32Data));  
IntMasterEnable();
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); /* again go to 80Mhz */


2. Since flash has 1Kb block selectable. Suppose I want to have 2Kb of flash as eeprom. I am using two last blocks of flash.
So I will use address like
FlashErase(0x3F800); /* 256*1024 - 1024 - 1024 */
FlashErase(0x3FC00); /* 256*1024 - 1024 */

Is it right?


3. I am using keil. I have made setting Project->option for trget->target->IROM1-> 0 to 0x3F800.
This is to tell compiler that now put flash code upto 0x3F800.
Is it correct?


4. Another workaround to MEM#14 is to "Copy the Flash Program/Erase code to SRAM and CPU executes the code from
SRAM."
How to do that in code. Is there any example code to how to do this?



i am using TM4C123gh6pm, driverlib 2.1.1.71 , keil 5.13.0.0

  • Hello VT

    With workarounds #1, #2 and #3, you do not need to have #4.

    Regards
    Amit
  • Hi Amit,

    1. I was asking if any example code on how to implement workaround#4 in case.
    2. What are these Non-volatile register programming? Are they inly FMPREx, USER_REG0 & BOOTCFG only?

    Thanks
  • Hello VT,

    1. We do not have a ready to use code for WA#4
    2. Yes, these are the NVM registers.

    Regards
    Amit
  • Hi Amit,

    I am using flash as eeprom & using last two 1KB block of flash for this.

    1. For erasing flash:
    SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); /* go to 40Mhz */
    IntMasterDisable();
    FlashErase(0x3F800); /* 256*1024 - 1024 - 1024 , delete second last block */
    FlashErase(0x3FC00); /* 256*1024 - 1024, delete last block */
    IntMasterEnable();
    SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); /* again go to 80Mhz */

    2. For programming flash
    SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); /* go to 40Mhz */
    IntMasterDisable();
    FlashProgram(pui32Data, 0x3F800U, sizeof(pui32Data));
    FlashProgram(pui32Data, 0x3F800U + 8U, sizeof(pui32Data));
    FlashProgram(pui32Data, 0x3FC00U, sizeof(pui32Data));
    FlashProgram(pui32Data, 0x3FC00U + 8U, sizeof(pui32Data));
    IntMasterEnable();
    SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); /* again go to 80Mhz */


    3. Are both these methods right.

    4. now how to read back the data from flash. i am using below method. Since I am reading from flah, so I think there is no need to slow down clock or disable master interrupt. Right? below is code. I have disabled slowing down of clock.

    // SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ );
    // IntMasterDisable();
    pui32Read[0] = (*(uint32_t *)(0x3F800U));
    pui32Read[1] = (*(uint32_t *)(0x3F800U + 4U));
    pui32Read[0] = (*(uint32_t *)(0x3F800U + 8U));
    pui32Read[1] = (*(uint32_t *)(0x3F800U + 12U));
    // IntMasterEnable();
    // SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); /* again go to 80Mhz */


    5. I have checked. Code is working,
  • Hello VT,

    All the steps are correct.

    Regards
    Amit