24.8 Error Correcting Code (ECC) and Flash Programming
The PIC32CX-BZ2 devices incorporate Error Correcting Code (ECC) features that detect and correct errors resulting in extended Flash memory life. For more details on this feature, see Prefetch Cache from Related Links.
ECC is implemented in 128-bit Quad Flash Words or 32-bit Single Word. As a result, when programming Flash memory on a device where ECC is employed, the programming operation must be, at minimum, four instruction Words or in groups of four instruction Words. This is the reason that the Quad Word programming command exists and why row programming always programs multiples of four Words.
For a given software application, ECC can be enabled at all times, disabled at all times or dynamically enabled using the ECCCTL Configuration bits in the CFGCON0 register. When ECC is enabled at all times, the Single Word NVMOP programming command does not function and the Quad Word is the smallest unit of memory that can be programmed. When ECC is disabled or enabled dynamically, both the Single Word and Quad Word programming NVMOP commands are functional and the programming method used determines how ECC is handled.
In the case of dynamic ECC, if the memory was programmed with the Singe Word command, ECC is turned off for that Word, and, when it is read, no error correction is performed. If the memory was programmed with the Quad Word or Row Programming commands, ECC data is written and tested for errors (and corrected if needed) when read. The following table describes the different ECC scenarios.
ECCCTL Setting | Programming Operation | Data Read | ||
---|---|---|---|---|
Single Word Write | Quad Word Write | Row Write | ||
Disabled | Allowed | Allowed | Allowed | ECC is never applied on a Flash read |
Enabled | Not allowed | Allowed | Allowed | ECC is applied on every Flash Word read |
Dynamic | Allowed but when used, the programmed word is flagged to NOT USE ECC | Writes ECC data and flags programmed words to USE ECC | Writes ECC data and flags programmed words to USE ECC | ECC is only applied on words that are flagged to USE ECC |
0
’).