Hi we use the MC56F8367 DSC in our system, and recently have set about using the data flash to retain user-supplied settings. By using the Codewarrior memory viewer I can see the data in the data flash (address 0x4000) and I have a checksum routine and a validation routine (which reads the flash and compares with the buffer which supplied the data) and both report ok.
At start-up after a power-down the flash data should be restored to the buffer, but this fails. To see the memory requires Codewarrior, and a re-program of the chip which I think resets the flash (at least, when I look at the flash data its back to all 0xFFFF. My Codewarrior settings for the flash are shown below, along with the code to write to flash.
Any ideas?
Thanks in advance!
Dave
void ReConfig(void)
{
int gs;
int rv;
int try;
volatile long waste;
unsigned long blocksize;
unsigned long addrf;
long csum;
//reset cpured led now that reconfiguration has happened
ledcon.cpured=false;
SetAnProg();
U.thisan.SerialDebugOn='N';
//put data into Factory Data Area
CopyForWrite();
csum=ChecksumBuffer();
F.cksbuff = csum;
//configured, so write it to flash
blocksize=(unsigned long)(&F.lastword-&F.memptr)*2;
for(try=0; try<2; try++)
{
addrf=((unsigned long)&F)*2;
IFsh1_SetWait(true);
rv=IFsh1_SetGlobalProtection(false); //unprotect all
//waste time
for(waste=0; waste<2000000; waste++) ;//do nothing
rv=IFsh1_SetBlockFlash(addrf,0x8000,blocksize);
//waste time
for(waste=0; waste<5000000; waste++) ;//do nothing
LogErr(0,603,0,0); //info- Write to flash
if(!VerifyBuffer())
{
LogErr(0,904,try,Current_Process);
}
else break;
}
}
Solved! Go to Solution.
Oh no! It was a flaw in the start-up logic. I have corrected it, and now I can get the system restarted by reading the data from the data flash memory.
Panic over.
Thanks for your input Fiona!
Do you mean that your data saved in data flash is erased after re-programming by CodeWarrior?
CodeWarrior will erase the flash before downloading new data to the flash. So, there won’t be any problem when you don’t use programming tool. The data flash won’t be erased after switching off power too.
The erase mode of CodeWarrior debugger was set in flash initialization file. The erase mode can be set as 'pages', 'unit' or 'all' in this file by command 'set_hfm_erase_mode'. About this command, please refer to 56800E Targeting Manual, which is usually placed in the directory below:
C:\Program Files\Freescale\CodeWarrior\Help\PDF\ Targeting_56800E.pdf
By default, the project uses the flash initialization file under:
C:\program files\Freescale\CodeWarrior for DSC56800E v8.3\M56800E Support\initialization
The erase mode defaults to the unit mode.
Fiona Kuang
Technical Information & Commercial Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Ok so I was correct in assuming the re-programming clears the data flash too.
However, the problem is that after data has been written to the data flash, and the system has been power cycled, it fails to load the buffer from the flash, and so the system does not run.
I wanted to check that I have correctly programmed the data flash. I'm checking my code for bugs, but I can't use the Codewarrior debugger to see what's happening, of course.
I should add that with power on the cpu board, I can use a re-set function in my code and this copies from data flash to ram correctly.
Oh no! It was a flaw in the start-up logic. I have corrected it, and now I can get the system restarted by reading the data from the data flash memory.
Panic over.
Thanks for your input Fiona!