The S12Z devices contain unmaskable machine exception interrupt for severe system problems.
The Memory Map Control module (MMC) generates this exception in the case of illegal memory access and uncorrectable ECC errors.
The MMCECn register is set to a non-zero value if an S12ZCPU access violation or an uncorrectable ECC error has occurred. At the same time when this register is set to a non-zero value, access information is captured in the MMCPCn (program counter) and MMCCCRn (CCR U, X and I bits) registers. The MMCECn registers are cleared by writing the value 0xFFFF.
Unfortunately, the exact address with corrupted data isn’t stored in any user-accessible register and this makes the debugging more difficult.
In the case of reading memory with an uncorrectable ECC error, the MMC causes jump to the address in the Machine Exception vector as soon as the current instruction finishes execution. This may be used in workaround code for detection of the exact address with corrupted data. See attached example code.
Note: The code detects only the first address of the phrase with uncorrectable corrupted data. The solution for detecting multiple ECC issues isn't included.
The execution of a machine exception code isn’t straightforward in this case. Please read the simplified procedure:
Note: Since the P-FLASH is protected by 39-Bit ECC Scheme, we should read at leats single word(byte) from every aligned 32bit phrases.
This code is only a simple example code and does not cover all conditions.
More details regarding simulating ECC issue at EEPROM and P-Flash: