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.

Using a section of the onboard Flash Memory of the TM4C129ENCPDTI3 to store log data

I'm trying to use a section of the TM4C129ENCPDTI3 Flash memory to store some log data in a circular fashion within one of the 16K sections.  I've computed a region safely outside/above the areas where the program is stored and wrote some code to erase and periodically write 32byte records consecutively until I get close to the end of the 16K section.


Problem is that after a write a few records, the system locks up and breaks the connection to my debugger (Blackhawk XDS100V2) .  Then its hard to re-establish the connection once this occurs.  I have to time the downloading of the program just write while I keep rebooting my board to get the debugger connect (I suspect before it gets to my test code for writing to the flash)  If  I comment out my writes I have not problems.

My code is very simple.  I just use these two functions:

ROM_FlashProgram()  // to write the data, yes its multiple of 4 bytes

ROM_FlashErase // to erase the 16K block (yes its on a 16K  - based address

And read my data simply by using a direct pointer and typecasting.

Are there other things I need to be doing in my erasing and writing?   I also check the return codes from the erase and program and do not get any errors.

Thanks,

Bill

  • Hello Bill,

    Based on the description of the issue, can you please confirm that the Sector being used in the same Flash Bank as where the program code is being executed? If yes, then could you instead use the other Flash bank.

    As an example if the code is in the lower 512KB, then try using the upper 512KB.

    Secondly, does the behavior change with changing the system clock to 16MHz instead of PLL clock if you are using the PLL as the system clock source.

    Regards

    Amit

  • Amit,


        I was using the upper 512KB,  So I switched to the lower and it works now.
        One question, If  I want to use the upper 512KB,  Is it necessary to define a section in the memory map/linker file - the .cmd file as a section and as writable ?

    Thanks,

    Bill

  • Hello Bill,

    Correct me if my understanding is correct or not: Your code is in the upper 512KB and the storage in lower 512KB works fine? If yes, then the issue is that execution and erase in the same bank is not allowed.

    You must define the 1MB as the full range of the linker command file as Read and Execute. The CCS is not aware of the writting mechanism.

    Regards

    Amit

  • Actually my code is in the lower 512KB and the storage is in the lower 512KB.  My current .map shows:

    MEMORY CONFIGURATION

             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      BOOT                  00000000   00020000  00000208  0001fdf8  R  X
      FLASH                 00020000   000e0000  0003f40c  000a0bf4  R  X
      SRAM                  20000000   00040000  00031e9f  0000e161  RW X

    We have a custom boot loader in the region from  0x00000000 - 0x00020000

    The application starts at 0x00020000  goes to about 0x0005F40C  (which is below 512KB - 0x00080000)

    I started my data storage area at:  0x00078000  and it works at this location.  But if I go above the 512KB range (> 0x000800000) there were problems.

    Bill

  • Hello Bill,

    I wrote a simple program to Program and Erase Flash. After every step it checks for the Flash Content and the program works fine. Also I noticed a typo in the last post "512KB range ( > 0x000800000)", seems like an extra "0" somewhere.

        //
        // Display the setup on the console.
        //
        UARTprintf("FLASH Upper Region Feature Example\n");

        ROM_FlashProgram(&ui32Data,0x80000,0x4);
        UARTprintf("After Program %x\n",HWREG(0x80000));

        ROM_FlashErase(0x80000);
        UARTprintf("After Erase %x\n",HWREG(0x80000));

    My linker cmd file looks like

    #define APP_BASE 0x00000000
    #define RAM_BASE 0x20000000

    /* System memory map */

    MEMORY
    {
        /* Application stored in and executes from internal flash */
        FLASH (RX) : origin = APP_BASE, length = 0x00100000
        /* Application uses internal RAM for data */
        SRAM (RWX) : origin = 0x20000000, length = 0x00040000
    }

    /* Section allocation in memory */

    SECTIONS
    {
        .intvecs:   > APP_BASE
        .text   :   > FLASH
        .const  :   > FLASH
        .cinit  :   > FLASH
        .pinit  :   > FLASH
        .init_array : > FLASH

        .vtable :   > RAM_BASE
        .data   :   > SRAM
        .bss    :   > SRAM
        .sysmem :   > SRAM
        .stack  :   > SRAM
    }

    __STACK_TOP = __stack + 256;

    Regards

    Amit