15.11 Error Detection
The NVMCON register includes two bits for detecting error conditions during a program or erase operation. They are Low-Voltage Detect Error, LVDERR bit (NVMCON[12]), and Write Error, WRERR bit (NVMCON[13]).
The WRERR is set each time the WR bit (NVMCON[15]) is set, initiating a programming operation. When the Flash operation is complete, indicated by hardware clearing the value of the WR bit (WR bit is set to ‘0
’), hardware updates the value in the WRERR bit to indicate if an error occurred. Firmware must check the value of the WR bit to see if the Flash operation completed before checking the value of the WRERR bit. When the WRERR bit is set, any future attempt to initiate programming or erase operation is ignored. WRERR must be cleared before commencing Flash program or erase operations.
The LVDERR bit is set when a Brown-out Reset (BOR) occurs during a programming operation. The only Reset that clears the LVDERR bit is a Power-on Reset (POR). Other Reset types do not affect the LVDERR bit. When the LVDERR bit is set, any attempt to initiate programming or erase operation is ignored. Clear the bit before commencing Flash program or erase operations.
In the software, manually clear both the WRERR and LVDERR bits by initiating a Flash operation (setting WR) referred to as NOP (0x00) (see the NVMOP bit fields).
Cause of Error | Effect on Programming Erase Operation | Indication |
---|---|---|
A low-voltage event occurred during a programming sequence. | The last programming or erase operation might not have completed. | LVDERR = 1 , WRERR = 1 |
A non-POR Reset occurred during programming. | Programming or erase operation is aborted. | WRERR = 1 |
Attempt to program or erase a page out of the Flash memory range. | Erase or programming operation is not initiated. | WRERR = 1 |
Attempt to erase or program a write-protected PFM page. | Erase or programming operation is not initiated. | WRERR = 1 |
Attempt to erase or program a write-protected BFM page. | Operation occurs, but the page is not programmed or erased. | WRERR = 0 |
Bus host error or row programming data underrun error during programming. | Programming or erase operation is aborted. | WRERR = 1 |