Hi Sourabh,
It is quite difficult to say what root cause is it in your case.
The system hangs directly on some EEPROM command?
What you mean by “system gets hang”? It means MCU reset or lost connection with debugger?
Could you please provide your code related to EEPROM read/write?
You cannot simultaneously read and write EEPROM. Did your software read EEPROM values inside any interrupts?
In that case, at least critical section of EEPROM commands has to be protected by disabling interrupts.
The all illegal accesses performed by the S12ZCPU trigger machine exceptions. Did you implement machine exception interrupt routine?
For example:
//==============================================================================
// Machine_Exception_ISR
//==============================================================================
interrupt 5 void Machine_Exception_ISR(void)
{
asm NOP: //place breakpoint here
//MCU reset:
//CPMUCOP = 0x01; //Initialize COP watchdog
//CPMUARMCOP = 0x00; //write any value except 0x55 or 0xAA cause MCU reset
}
EEPROM must be erased prior programming. Commutative writes are not allowed and it may cases double bit ECC error detection leading to machine exception.
In attachment is simple S12Z EEPROM example code.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------