LPC55xx Erased Memory State, 0 or 1?

Showing results for 
Search instead for 
Did you mean: 

LPC55xx Erased Memory State, 0 or 1?

No ratings

LPC55xx Erased Memory State, 0 or 1?

Previously, I wrote two articles about LPC55xx AHB read ( How to fix AHB Read HardFault Error) and LPC55xx FLASH alignment (Why FLASH Program cannot Success? ). In this article, we will go on investigating LPC55xx erased memory state.

For most of NXP MCU, the erased FLASH state is 0xFF. Writing action is to change 1 to 0. However for LPC55, when we perform mass erase or section erase, we see the related memory turns to all 0 in MCUXpresso IDE debugger Memory view.


This all-0-erased-status confuses many LPC55 beginners. Is this real memory state? The answer is yes, IDE debugger display is correct. LPC55xx FLASH uses 0x00 as erased value, which is opposite to most of the other FLASH devices which use 0xFF as erased value)

There is no way to verify the erased FLASH state with code in runtime. NXP enhanced LPC55xx FLASH with ECC added. This means that there is now a functional block between the read entity (for example the CPU) and the FLASH itself. When erasing, both the erased FLASH and its ECC are set as 0. The reading can’t be successful if the erased memory and its ECC don’t match.

Thus we can’t read memory in erased state. AHB read hardfault error is produced if do so.  Because of ECC mechanism, you can't read FLASH until you have written to it. see  How to fix AHB Read HardFault Error

The User's Manual mentions the reading and writing operation in UM11126 chapter 5.7.13:

When writing, parity is automatically computed and stored alongside user data. When reading, data and parity are used to reconstruct correct data, even in the case of a 1-bit error.

When reading an erased location, an uncorrectable error is flagged. Use the “blank check” command to test for successful erase.

The LinkServer debug in MCUXpresso IDE takes some precautions to avoid this problem while programming the FLASH before starting a debug session. That’s the reason we can see erased memory state in debugger memory view window,

Admittedly, this is something not really pre-eminent in the documentation. The only reference we could spot is in UM11126. See below:

“ The selected pages are checked for the erased condition (all 0 including parity)”



Thanks for the valuable comment from Radu Theodor Lazarescu.

Labels (1)
Version history
Revision #:
3 of 3
Last update:
‎09-03-2020 04:51 AM
Updated by: