<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>flash update / swap</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11752/flash-update-swap</link><description>Dear developers, 
 As we know, nrf51 has a maximum flash erase / write cycles of 20.000 times. So, in my code, I have implemented a counter that checks if max. flash write cycles has been reached. If so, my code will write in the next consecutive address</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Feb 2016 12:15:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11752/flash-update-swap" /><item><title>RE: flash update / swap</title><link>https://devzone.nordicsemi.com/thread/44444?ContentTypeID=1</link><pubDate>Mon, 08 Feb 2016 12:15:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9eef0713-4996-47bc-a42a-3353c2bfd001</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;To update a value in flash it needs to be erased first as the write operation can only change existing one&amp;#39;s into zeroes and not the other way around. Also, flash erase has to be done 1024 bytes at a time (size of flash page on 51). So in order to update a single word in flash you would have to erase the entire flash page first  followed by the write. Thus, frequent update data at the same address is not ideal for long flash endurance.&lt;/p&gt;
&lt;p&gt;Pstorage may not be the best option in your case if you expect the number of cycles to exceed 20,000. An alternative could be to use the softdevice&amp;#39;s flash API directly, and write each updated value to the subsequent address in order to fill the flash page before erasing the page.&lt;/p&gt;
&lt;p&gt;The SDK team has also released two new modules for handling of persitent memory that toghether reduces the number of page erases: &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/lib_fstorage.html?cp=4_0_0_3_30"&gt;fstorage&lt;/a&gt;  and &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/lib_fds.html?cp=4_0_0_3_29"&gt;fds&lt;/a&gt;. But note that these modules are currently releases as experimental.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>