S12XHY256 - P-Flash Sector erase problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12XHY256 - P-Flash Sector erase problem

485 Views
S12XHY256Flashd
Contributor I
HI, I'm facing a problem with flash erasing. But the same SW works fine if I single step or if I check the status with break point. Erase command = 0x0A Erase address = 0x7E0000 Erase length = 0x1E000 Obervation while SIngle stepping: Erase length (0x1E000) is checked periodically and decremented (0x400) sector by sector till the erase length becomes zero. Flash erased successfully from 0x7E0000 to 0x7FE000 Observation with breakpoint in FSTAT status check: Erase length (0x1E000) is checked periodically and decremented (0x400) sector by sector till the erase length becomes zero. Flash erased successfully from 0x7E0000 to 0x7FE000 Observation during Free RUN: Erase length is checked and first sector is erased. FERSTAT has the value 0x03 FECCR has the value 0x7F Then PC is loaded with value 0 and SP hass some junk value SW does not return to normal execution after erasing first sector Please let me know whether similar problem was faced or any solution for this. 1) Why the error flag is getting set? 2) Why the same problem is not observed with breakpoint or single stepping? 3) Will this error flag generate any reset? because of which PC is loaded with 0? 4) Any possible root cause or solution? Please suggest.
0 Kudos
1 Reply

323 Views
S12XHY256Flashd
Contributor I
SW routine for erasing: void ExpFlashErase( tFlashParam *fp ) { tFlashLength flashLength; flashLength = fp->length; fp->errorCode = kFlashOk; fp->errorAddress = fp->address; fp->reserved1 = 0; while ( (flashLength>0) && (fp->errorCode == kFlashOk)) { /* Perform a sector erase */ fp->eraseCmd = ERAS_CMD; FErase(fp); /* Loads the CCOB registers and starts the erase command */ fp->errorAddress += (unsigned long)fp->eraseSize; fp->reserved1++; if(flashLength > (unsigned long)fp->eraseSize) { flashLength -= (unsigned long)fp->eraseSize; } else { flashLength = 0; } } } While is executed only once and then abruptly the control jumps some where. Mostly PC loaded with 0.