43/50
M28W160ECT, M28W160ECB
Figure 20. Erase Flowchart and Pseudo Code
Note: If an error is found, the Status Register must be cleared before further Program/Erase operations.
Write 20h
AI03541b
Start
Write Block
Address & D0h
Read Status
Register
YES
NO
b7 = 1
YES
NO
b3 = 0
YES
b4, b5 = 1
VPP Invalid
Error (1)
Command
Sequence Error (1)
NO
NO
b5 = 0
Erase Error (1)
End
YES
NO
b1 = 0
Erase to Protected
Block Error (1)
YES
erase_command ( blockToErase ) {
writeToFlash (any_address, 0x20) ;
writeToFlash (blockToErase, 0xD0) ;
/* only A12-A20 are significannt */
/* Memory enters read status state after
the Erase Command */
} while (status_register.b7== 0) ;
do {
status_register=readFlash (any_address) ;
/* E or G must be toggled*/
if (status_register.b3==1) /*VPP invalid error */
error_handler ( ) ;
if ( (status_register.b4==1) && (status_register.b5==1) )
/* command sequence error */
error_handler ( ) ;
if (status_register.b1==1) /*program to protect block error */
error_handler ( ) ;
if ( (status_register.b5==1) )
/* erase error */
error_handler ( ) ;
}