AnsweredAssumed Answered

BF506F FLASH unlock cause crash!

Question asked by popzhuo on May 28, 2014
Latest reply on Jul 14, 2014 by popzhuo

I use following code to unlock the flash sector, these code is OK when I load program from JTAG.

But the program is load from FLASH, the 1st line of unlock code [WriteFlash( 0x20000000, 0x60 )] cause crash.

I don't know why this happened.

 

// unlock this block

WriteFlash( 0x20000000, 0x60 );

WriteFlash( 0x20000000, 0xD0 );

 

Hope to get your help! Thank you!

 

-----------------------------------------------------------------------------------------------------------------

ERROR_CODE WriteFlash( unsigned long ulAddr, unsigned short usValue )

{

 

    // disable interrupts before performing the load or store operation

    // [refer warning: page 6-71 BF533 HRM]

    unsigned int uiSaveInts = cli();

 

    // set the address

    unsigned short *pFlashAddr = (unsigned short *)(ulAddr);

 

    *pFlashAddr = usValue;

 

    // Enable Interrupts

    sti(uiSaveInts);

 

    // ok

    return NO_ERR;

}

Outcomes