chipKIT® Development Platform

Inspired by Arduino™

PIC32MZ Flash Endurance Questions

Created Mon, 30 Jan 2017 16:32:21 +0000 by photomankc


Mon, 30 Jan 2017 16:32:21 +0000

So before I ask, I did pull the datasheet and a document on the Flash Programming Specifications but I did not have much success finding the answer to this. I've seen some people quote the PIC32 as having 1,000 write cycle endurance on the flash (which did not really feel like much breathing room). Then I saw something saying that newer chips had 10,000 or 20,000 cycles which gives a lot more headroom for prototyping. What I can't find is the number for the MZ's in the WiFire, Rev C boards.

Saw some reference to 10,000 for the MX parts which seems like it ought to be similar to the MZ's but just not having luck figuring out where the spec is listed.

My other question is, how does the Flash handle wear on these boards? Does it handle wear leveling internally, or do you quickly wear out the first few hundred KB of the flash as you program and test smaller code sizes and the remaining megabyte plus of Flash is untouched? I was just curious how a failure would manifest. Would you just not be able to program the board, or would it fail much uglier when some bits fade away at some later point and things go off the rails?

If there is something I should be reading that I missed (I assume there is) please feel free to point my dumb butt that way and I'll go RTFM. Just a couple of questions that occurred to me as uploaded 20 versions of code trying to track down an error of mine in reading serial input. I hate parsing strings!


Mon, 30 Jan 2017 17:54:41 +0000

Looking at our internal documentation, I don't see that any wear leveling taking place. The only thing I really see that's relevant is this sentence:

"The split gate cell design and thick oxide tunneling injector attain better reliability and manufacturability compared with alternate approaches."

The MX parts, generally, do not have the same Flash as the MZ parts, so the endurance will be different. The oldest MX parts only have 1000 cycle endurance. The other MX parts show 20,000 E/W endurance.

The MZ base endurance (without ECC) is 10,000 E/W cycles. Adding ECC allows for the Flash to develop bit errors, and recover from them. Thus the endurance extends to 20,000 E/W cycles. However, ECC imposes a bit of a speed penalty, so the points at which the wait states are added are different. Also, the Flash has to be programmed via quad-words in order to gain the extra ECC bits. Single bit errors are recoverable in any of the 128-bits thus programmed. Double-bit errors are not, however. Interrupts can be triggered in either case.


Mon, 30 Jan 2017 18:22:56 +0000

Thanks for the quick answer! As always 1hr after I give up looking I run into the answer to question one on page 622 of the data sheet under electrical specs. Just didn't think to look there. So it sounds like the answer is 10,000. Which definitely raises less alarm as I bumble my way through this project. I'll buy a second board to do some testing of subsections of my code on and that should be enough insurance.

On the second question it seems the answer is that I can expect that the front end of the Flash is going to wear out first and so will be where an uncorrectable problem develops. From reading up on flash it sounds like two things can occur. One is the bit leaks away sooner than the 10 year retention specification and eventually the bit can no longer be programmed. Although in truth I'm not clear if those are for different types of Flash. At any rate, it sounds like the 10,000 mark is not a wall but the start of an incline in failure likelihood.

Thanks for the insight from behind the curtain!


Mon, 30 Jan 2017 19:43:05 +0000

Another thing to consider is that those values you see in the data sheet are really, really conservative. I remember a fab tour (back when Microchip would actually take you through one of their fabs during MASTERs) many years ago where I asked one of their flash memory guys how realistic those numbers in the datasheet are. His answer was that under the worst case conditions (which I think are maximum voltage maximum temperature), they wanted to make sure they had a 10x factor over some large sample (like 1000 pieces or something). So if a part is rated to 10K writes, then Microchip is actually targeting 100K minimum good writes at maximum rated voltage and temp across 1000 sampled parts from the line.

Since temperature has a huge impact on how fast flash goes bad, you should not be surprised if you can get 100x or more of the rated writes out of a 'typical' CPU at room temps.

Bottom line - you don't have to worry about these flash cells wearing out except if you're writing code that constantly erases them.



Mon, 30 Jan 2017 21:26:04 +0000

Good info and it makes sense. That way you are always exceeding the spec and making people happy.

I learned my lesson on writing to Flash from within a program early on. I added an external EEPROM to this project just to avoid any need to write to flash in the program. I recall messing up an if() statement on my Uno32 that resulted in data being written to the MCU's simulated EEPROM without me realizing it. It was hit every second for an hour or two before I caught it. I was pretty ticked when I caught that. I'd rather trash a couple dollars and 8 pins than a $40 to $80 board. I can always swap to the simulated EEPROM once the program is nearly complete and proven.

Jacob Christ

Tue, 07 Feb 2017 19:01:51 +0000

I think Keith at Digilent did some testing and found that he could do millions of writes at room temperature. I seem to remember something about him have to write and erase continuously for close to a month to destroy the chip.

The EEPROM library for chipKIT uses a table to keep track of your values. If you only write a few values to EEPROM it could take hundreds of writes to EEPROM to even cause a single erase cycle.