MC56F8367 Write to Data Flash problem.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MC56F8367 Write to Data Flash problem.

1,119件の閲覧回数
Signalds
Contributor II

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

ERR_BUSY8Device is busy

 

How do I get my data written to the Data-flash?

 

Regards

Dave

ラベル(1)
0 件の賞賛
返信
1 返信

940件の閲覧回数
johnlwinters
NXP Employee
NXP Employee

Hi,

Its your choice if you want to use word or byte addressing.  I'll show you both.  Which one is in force depends on the Processor Expert routines that you pick.

Here is the sample code:

void main(void)
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
 
  // write badf000d to data flash using word at a time method:
  IFsh1_SetGlobalProtection(FALSE);  // unprotect the data flash (see PEx properties IFsh1).
  IFsh1_EraseFlash(0) ;              // there is only one data flash block to chose from
  IFsh1_SetWordFlash(0x4001, 0x000d); // write badf000d to flash a word at a time
  IFsh1_SetWordFlash(0x4000, 0xbadf); // using word addresses
 
  //write 01020304 to data flash using byte at a time method:
 
  IFsh1_SetByteFlash(0x8004, 0x01);
  IFsh1_SetByteFlash(0x8005, 0x02);
  IFsh1_SetByteFlash(0x8006, 0x03);
  IFsh1_SetByteFlash(0x8007, 0x04);
 
 
  // Note, 8004 byte address is like the 4002 word address, but 8004 byte address
  // only addresses a byte.

 

  for(;;) {}
}

And the results are as follows after running code as observed with CodeWarrior 8.3 for DSC (best choice of tool for this family of devices):

New Bitmap Image.bmp

0 件の賞賛
返信