-
An interesting comment was made in one of @DrAzzy's post that by writing to some areas the device may become read only.
That was the DS2xxx OneWire eeproms, which has the status registers as part of the normal address space.
I looked a bit more at the datasheet....
- Erase can only be done by sectors.
- After erase, everything will be 255, and you can only write 1's to 0's, not the other way around (ie, you need another erase to rewrite).
- Can write 256 bytes at a time.
So to make this work:
- pgsz should be specified as 256
- erase() method would need to be written
- write() would need to check that it can write the content without erasing it first. Read/Modify/Write will be tricky because the pages are larger than the ram on most boards, so you need someplace to stuff all that data while you erase it and wait to rewrite it.
.....
In any event, he can't read the status register with my module, cause I didn't put that feature in (I2C eeproms don't have a status register, and on OW, they're very different), though it can certainly be done manually, and he should do that and report the results back. A function to read and write the status register on SPI eeproms might not be a bad thing to add to the AT25 module, but it's normally superfluous.
- Erase can only be done by sectors.
@Vishnu, can you read the status/write protection information of the M25P16? Did you check the soft bits that control write protection of the segments? M25P16 has - like practically all other such devices have - a multi-level protection from accidentally write to areas that should not be overwritten/written to. Other that that - as consulted from the data sheet - I do not see any issue you should face, because @DrAzzy's AT25 module does what such devices need to be read from and written to.
An interesting comment was made in one of @DrAzzy's post that by writing to some areas the device may become read only. In the devices I used so far, this is always controlled by the status registers an not just by address areas. M25P16 has this 'nice' feature of hard protection bits which can only be written once... and then the related protected areas become read-only for ever (similar to fuse/anti-fuse, OTP - one time programmable - ROMs).