AnsweredAssumed Answered

Flash Sector Erase Issue

Question asked by tafeng chung on Aug 24, 2017
Latest reply on Sep 1, 2017 by Edward Karpicz

My MCU is 9S12XEP100() , I try to Erase a part(sector) of Flash. 

when I erase address 0x7A0000, it's ok

but erase address 0x7C0000, program will run out(crash)

 

//************************************************************************************************************

source code as below : 

PFlash_EraseSector(address){

 while((FSTAT & FSTAT_CCIF_MASK) == 0){
_FEED_COP();
}; 
FSTAT = 0x30; //clear ACCERR and PVIOL

FCCOBIX = 0x00;

FCCOB = 0x0A00 | ((address & 0x007F0000)>>16);

FCCOBIX = 0x01;

FCCOB = (address & 0x0000FFF8);

FSTAT = 0x80; //launch command
while((FSTAT & FSTAT_CCIF_MASK) == 0){
_FEED_COP();
}; //wait for done

if((FSTAT & (FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK)) != 0)
return FlashEraseError; //error
else
return noErr; 

}

Outcomes