I am very glad to see your replies. and thank you very much for everybody. :smileyhappy:
One thing need to confirm is just the MCU lost the code on address 0x6000 to 0x6400, we don't know the specific reason ,we just guess the possible reason is the 0x6000~0x6400 flash was erased accidentally when we used S12C flash for data EEPROM emulation.
According to your analysis, I do check the software, and the result as follows:
1. The function which is for flash erase, got the address by taking pointer of the array, and it desn't use bit shift. The function is like that:
fburner ( (unsigned int *)&InputEepromInFlashRecorded, (unsigned int *)&InputEepromInRam, sizeof(InputEepromInFlashRecorded)/2);
"InputEepromInFlashRecorded" is an array which defined by myself.
2. Unexpected interrput.
Now we used 13 interrupts, they are :System Reset,Real Time Interrupt,Standard Timer Channel 0~7,Standard Timer Overflow,SCI,PortP Interrupt. Other unimplemented Interrupts have an same interrupt function. The function is like that:
__interrupt void unimplementISR( void )
{
return;
}
So I think unexpected interrupt will not cause flash erase.
Another thing: I changed the highest priority interrupt which is standard timer channal 0 interrupt( HPRIO=0xEE;).
3. Stack overflow
Now stack size is 0x100 bytes.and I didn't clear the I-bit and other interrupts were forbid during the routines was running in any interrupt. So I think stack overflow is almost impossible, however, I haven't test it, I am not sure.
The variables which are placed under stack are static variables, and these variables are used for SCI communication and other control logic, there is no relationship with flash address.
4. Flash Security
Now I didn't used flash security function( $FF0F=0xFE ); my colleage told me the flash was erased maybe by BKGD port for electrical noise. If we used this function of flash security, all flash memory will be protect and flash was erased by BKGD will be prevented. So how do you think about it?
According to the trouble shooting rules, I think now the urgent thing is how to repeat this issue, then we can find the real cause.
Thank you again for all of you!