Hi Rajiv,
RAM ECC single bit fault:
The ECC check is performed only during Read Access and Non-aligned Memory Write Access.
So, write command to address 0x1000 (aligned access) will not check ECC (just write new value and new ECC). The write to address 0x1001 (non-aligned access) will perform ECC check due to read-modify-write operation. Any read operation on RAM will perform ECC check.
According to RM:
“If a single bit ECC error was detected, then the SBEEIF flag is set.”, “If the logic detects a single bit ECC error, then the module corrects the data, so that the access initiator module receives correct data. In parallel, the logic writes the corrected data back to the memory, so that this read access repairs the single bit ECC error. This automatic ECC read repair function is disabled by setting the ECCDRR bit.”
So, this automatic fixing mechanism is driven by ECCDCMD_ECCDRR bit (by default - enabled).
The necessity of single bit ECC fault interrupt enabling depends on your application safety requirements.
If you enable this interrupt, you should at least clear ECCIF_SBEEIF flag. Additionally, you may record this event and/or signalize this error to the superior system.
EeProm/Flash Single Bit fault:
Yes, the faulty location itself is not corrected by ECC logic, but the read data is already corrected by ECC.
The only way for fixing single bit ECC fault on EEPROM/Flash is the read of a particular sector, erase them and write it back that ECC values are correctly restored.
The difference between EEPROM and Flash is only in sector size in that case and that you use slightly different commands. Anyway, at least the critical part of the Flash erase/program operation must be executed from RAM because S12ZVL contains just one Flash block. By the critical part, I mean writing 1 to FSTAT_CCIF bit followed by waiting on command finish (FSTAT_CCIF is set again). If interrupt vector table and interrupt routines are in Flash, it is necessary to disable interrupts during this critical part.
RAM/EeProm/Flash Double Bit faults:
You are right that there isn’t any interrupt enable bit for such faults. However, the double bit ECC faults are uncorrectable errors and they will trigger Machine exception (interrupt vector 5).
The S12ZCPU machine exceptions are triggered upon detection of illegal memory accesses and uncorrectable ECC errors.
Note: The Machine exception is not an interrupt. There is no stack-frame created for a Machine Exception so simply calling "RTI" (which expects a stack-frame) at the end of the Machine Exception routine will result in a crash.
The difference is explained here:
http://www.nxp.com/files/microcontrollers/doc/ref_manual/S12ZCPU_RM_V1.pdf
("Chapter 7, Exceptions").
Therefore the correct recovery action should be rather (signalize error and) MCU reset.
Some very simple example code of the Machine exception routine may be found here:
https://community.nxp.com/docs/DOC-330312
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------