Hi Cristian. Very useful library. I was doing some testing with an instance of FlashClass larger than 8192 bytes (ROW_SIZE), and I found an issue. My store was 65536 bytes, and I found that if I called store.erase(), only the first row (8192 bytes) was erased. The issue is the use of INTFLAG.bit.DONE, which does become true when a command completes, but needs to be cleared before doing another command. What you have in erase(ptr) now is:
The DONE flag is never cleared, so when erase() is called for a store larger than one row, and the code above gets called more than once with no delay, the DONE flag is already set and the erase does not occur. My fix was to use the READY flag rather than the DONE flag, the same as you do for SAMD21. The READY flag is cleared automatically when you start a command, so it never has to be "manually" cleared, as is required for DONE. The code below fixes the problem, and it's nice that it is the same logic as SAMD21.
Hi Cristian. Very useful library. I was doing some testing with an instance of FlashClass larger than 8192 bytes (ROW_SIZE), and I found an issue. My store was 65536 bytes, and I found that if I called store.erase(), only the first row (8192 bytes) was erased. The issue is the use of INTFLAG.bit.DONE, which does become true when a command completes, but needs to be cleared before doing another command. What you have in erase(ptr) now is:
The DONE flag is never cleared, so when erase() is called for a store larger than one row, and the code above gets called more than once with no delay, the DONE flag is already set and the erase does not occur. My fix was to use the READY flag rather than the DONE flag, the same as you do for SAMD21. The READY flag is cleared automatically when you start a command, so it never has to be "manually" cleared, as is required for DONE. The code below fixes the problem, and it's nice that it is the same logic as SAMD21.
write() must also be modified to use READY instead of DONE in the logic for both PBC (page buffer clear) and WP (write page).