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.

RTOS/TM4C1294NCPDT: Flash write and read is not happening

Part Number: TM4C1294NCPDT

Tool/software: TI-RTOS

Hi,

I am working with the TM4C1294NCPDT EVM TI RTOS controller, I can find functions for flash memory operations in flash.c file,

FlashUserSet(userreg0, userreg1);

FlashUserGet(&userreg0, &userreg1);


I want to write and read the flash user registers. the following is my code:

int main()

{

uint32_t value1 = 12345678;

uint32_t value2 = 12345678;

 

 FlashUserSet(value1 , value2);

System_printf("flash variables are %d %d\n", value1, value2);

System_flush();

FlashUserGet(&value1 , &value2);

System_printf("flash variables are %d %d\n", value1, value2);

System_flush();

}

The above prints:

flash variables are 12345678 12345678

flash variables are 0 0

My question:

1. why the function is not writing the 32bit data to the flash user register?

since its not writing the data, when I read it, its giving value as 0.

2.suggest me any other way to access flash memory and read back the data.

  • It looks like the flash user variables had previously been set and saved to a 0 value. Did you check the return value from FlashUserSet()?
  • hi Bob Crosby,
    I have complied the below code, and the return value of each function is 0. That I have captured and mentioned below.

    /*Source code */
    uint32_t value1 = 12345678;

    uint32_t value2 = 12345678;

    vui32FlashRet = FlashUserSet(value1 , value2);
    System_printf("flash variables are %d %d\n", value1, value2);
    System_printf("Return value %d\n", vui32FlashRet);
    System_flush();

    vui32FlashRet = FlashUserGet(&value1 , &value2);
    System_printf("flash variables are %d %d\n", value1, value2);
    System_printf("Return value %d\n", vui32FlashRet);
    System_flush();

    /*printed values in console */
    flash variables are 12345678 12345678
    Return value 0
    flash variables are 0 0
    Return value 0



    Regards,
    Manohar
  • Perhaps the flash user registers on your device have already been programmed. If you erase the device so it no longer has your code in it, then do a power-on-reset. Now connect with CCS and look at the FLASH_USERREGn in the "Registers" window as shown in the picture below:

    If your device, like mine, shows something other than 0xFFFFFFFF in FLASH_USERREG0 or 1, they have already been programmed and saved. When you write to these registers again, the value you write is "ANDED" with the value already there. (The flash can only be programmed 1's to 0's.) This may explain why you always read 0's.

  • Hi,

    by default I am getting the register value as below, Even if write anything, no changes to these registers.

    Regards,

    Manohar

  • It appears that your FLASH_USERREG0 and FLASH_USERREG1 have already been set to zero and committed. Since flash bits can only be programmed from 1 to 0, you cannot make any changes to these registers until they are erased. The only way to erase the Flash User registers is to follow the “Recovering a "Locked" Microcontroller” procedure. From page 614 of the datasheet.

    This can be done with CCS.