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!
-----------------------------------------------------------------------------------------------------------------------
Hi RadekS,
System cannot hangs directly on the EEPROM command.
When I ON-OFF the system continuously then after some iteration system hangs.
System hangs means it doesn't come out of the one while loop which is before EEPROM read/write operations, but if I remove EEPROM
read/write then it is working OK.
Software doesn't read EEPROM in any interrupt.
I haven't implemented any exception in software.
In attachment you find the EEPROM read/Write commands.
Regards,
Sourabh.
Hi Sourabh,
Thank you for more details.
1. What means “ErrF==0ff”, shouldn’t be there “ErrF==0xff”?
2. If I understood correctly, you want write 32bit number into EEPROM. The smallest portion of EEPROM which could be programmed is one word = 16bits (Program EEPROM command could program 1..4 words). It doesn’t have any sense to divide temp_id into bytes, you could write whole temp_id variable by single command. Programming address must be aligned to word (global address [0] = 0). Target area of EEPROM must be erased prior programming.
3. It seems that you don’t handle error codes from EEPROM routines. Therefore you don’t see that your commands failed.
Please look at EEPROM write implementation in my example code.
You could use for example such code:
error = EEPROM_Program(TEMP_ID_ADDR, temp_id, 2);
instead your huge for loop.
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!
-----------------------------------------------------------------------------------------------------------------------