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.

TM4C123 Issues writing to Flash and reading back

Other Parts Discussed in Thread: TM4C123GH6PZ

Hello,

I am using the Flash memory in TM4C123GH6PZ to store non-volatile data. To ensure read/write integrraty I store a 'Flag' in the first page. Next I store the non-volatile data in subsequent pages. On power on reset I read the Flag and check its validity. if the Flag is valid i use the non-volatile data, else I re-write the default non-volatile data and also the Flag in Flash.

The code snippet is as below:

FlashFlagRead();
if(FlashFlag[0] != FLASH_FLAG)
{
FlashFlagWrite();
do
{
SaveProgramDefault(i);
i++;
}while(i<PROGRAM_MAX_COUNT);
}

When I execute the first FlashFlagRead and the if statement, the match fails and the code enters the if clause. The FlashFlagWrite() is executed and subsequently the do..while loop.

On poweron reset, when the FlashFlagRead is executed again, the Flag is invalid again. Interestingly if I execute FlashFlagRead() immediately after FlashFlagWrite(),  get the correct Flag value.

I would appreciate if you could suggest a solution.

Thanks for your time.

Regards,

Hemant

  • Hello Hemant,

    Good description of the issue but you must understand that none of us have the description of FlashFlagRead, FlashFlagWrite or from where FlashFlag[0] gets it value....

    Details on the sub-functions if they are custom is required for any analysis.

    Regards
    Amit