M58CR064C, M58CR064D, M58CR064P, M58CR064Q
Figure 27. Protection Register Program Flowchart and Pseudo Code
Start
Write C0h
protection_register_program_command (addressToProgram, dataToProgram) {:
writeToFlash (bank_address, 0xC0) ;
Write Address
& Data
Read Status
Register
writeToFlash (addressToProgram, dataToProgram) ;
/*Memory enters read status state after
the Program Command*/
do {
status_register=readFlash (bank_address) ;
/* E or G must be toggled*/
NO
SR7 = 1
YES
NO
SR3 = 0
YES
NO
SR4 = 0
YES
NO
SR1 = 0
YES
End
VPP Invalid
Error (1, 2)
Program
Error (1, 2)
Program to Protected
Block Error (1, 2)
} while (status_register.SR7== 0) ;
if (status_register.SR3==1) /*VPP invalid error */
error_handler ( ) ;
if (status_register.SR4==1) /*program error */
error_handler ( ) ;
if (status_register.SR1==1) /*program to protect block error */
error_handler ( ) ;
}
AI06177
Note: 1. Status check of SR1 (Protected Block), SR3 (VPP Invalid) and SR4 (Program Error) can be made after each program operation or
after a sequence.
2. If an error is found, the Status Register must be cleared before further Program/Erase Controller operations.
65/70