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