Hi Kumada san,
Unfortunately, there is no blank check command for S25FL064L device. The only way to check whether the sector is programmed or erased is to read the particular sector and compare each byte with FFh. If all bytes are FFh it means the sector is erased. However, even if one bit is found to be zero, it means the sector is programmed and needs to be erased before another program operation.
Please let me know if you need any further assistance from our side.
Hi Kumada san,
There are two ways in which this problem can be solved -
- The customer can maintain a lookup table for sectors which are programmed and erased. Whenever a sector is programmed or erased, the status of that particular sector should be updated in the look up table. Before programming any particular sector, the status for it should be checked in the look up table and then depending upon its status either the sector should be erased before programming or should be programmed directly.
- Before programming a particular sector, the entire sector should be read and stored in a buffer. Each byte of that buffer should be compared with FFh. Even if one byte is found to be mismatched the sector should be erased before reprogramming.
The steps to check whether a 4KB sector is erased or programmed are as follows -
- Read 4KB (4096 bytes) from a particular sector and store it in a buffer (rxBuffer).
- Compare each byte in the buffer with 0xFF.
- As soon as a mismatch is found, update a flag (temp).
- Depending upon the final status of the flag, decide to erase or program the sector.
Sample function -
#define EQUAL 1
#define NOT_EQUAL 0
int Blank_Check(uint8_t rxBuffer)
int temp = EQUAL;
if(rxBuffer[i] != 0xFF)
temp = NOT_EQUAL;
Please let me know if you have any further queries.