Recently we have started to try to use the data flash to hold various sytem settings. I'm not having any success at getting the routines to write to flash.
The flash is located at 0x4000, but the routines require the address to be x2, along with the source address and the block size (unless I am mis-reading the documentation!)
'F' is the name of the source data area which is to be written to flash, and 'CopyForWrite() is a function to copy the data into the 'F' buffer from elsewhere.
My code for writing is as follows:-
/*---------------------------------------------------------*
Write to Flash memory and Re-initialise
*---------------------------------------------------------*/
void ReConfig(void)
{
int gs;
int rv;
volatile long waste;
unsigned long blocksize;
unsigned long addrf;
long csum;
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;
addrf=((unsigned long)&F)*2;
IFsh1_SetWait(true);
rv=IFsh1_SetGlobalProtection(false); //unprotect all
//waste time
while(IFsh1_Busy(0)) /*wait!*/;
rv=IFsh1_SetBlockFlash(addrf,0x8000,blocksize);
//waste time
while(IFsh1_Busy(0)) /*wait!*/;
LogErr(0,603,0,0); //info- Write to flash
if(!VerifyBuffer())
{
LogErr(0,904,0,Current_Process);
//failed to restore
return;
}
....etc
If I look at the return value (rv) from the IFSH1_SetBlockFlash() function, it is set to 8, which I checked is
How do I get my data written to the Data-flash?
Regards
Dave