24.10 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 (i.e., WR bit is set to ‘0
’), hardware will update 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. The LVDERR bit must be cleared before commencing Flash program or erase operations.
Cause of Error | Effect on Programming Erase Operation | Indication |
---|---|---|
A low-voltage event occurred during a programming sequence. | The last programming or erase operation may 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 |