You can chat about native SDK questions and issues here.

User avatar
By Agentsmithers
#81632 Hi Everyone, Currently I am using SPI_FLASH_ERASE_SECTOR to write the first few bytes of the first page to store network data.. but this seems kinda like overkill to have to keep wiping a sector each time just to write the first four bytes over again. Anyone have any suggestions on a better way to store this data in SPI or another way? (I prefer not to use RTC because I would like to cover for Power outages).

Thank you!
User avatar
By rudy
#81634 Once you change a location then the only way to change it is to erase the whole sector.

I'm not familiar with writing to these flash chips but this is what I am pretty sure is happening. The erased state is all bits having 1s in them. When you program a byte what is happening is the bits that need to be 0 is being programmed and the 1s are left alone. Once a bit is programmed as a 0 the only way to make it a 1 is with an erase cycle. Erase can not be done on an individual location, only a whole sector.

What I had done with eeproms long ago was to program a set of data. When I had to change it with new data I would grab the next set of location above what I had just programmed. On the old data (an index pointer) I would write all 0s indicating that those locations had been used and are now old. I could do a second write to those byte locations but I could only make 1s into 0s. I was doing this because of the limited number of writes I could do on a location.
User avatar
By Agentsmithers
#81635
rudy wrote:Once you change a location then the only way to change it is to erase the whole sector.

I'm not familiar with writing to these flash chips but this is what I am pretty sure is happening. The erased state is all bits having 1s in them. When you program a byte what is happening is the bits that need to be 0 is being programmed and the 1s are left alone. Once a bit is programmed as a 0 the only way to make it a 1 is with an erase cycle. Erase can not be done on an individual location, only a whole sector.

What I had done with eeproms long ago was to program a set of data. When I had to change it with new data I would grab the next set of location above what I had just programmed. On the old data (an index pointer) I would write all 0s indicating that those locations had been used and are now old. I could do a second write to those byte locations but I could only make 1s into 0s. I was doing this because of the limited number of writes I could do on a location.

I fully understand. Thank you sir!