Microcontroller Flash Memory 101


What comes to your mind??? When you hear that word…

Probably your brain skimming through its own memory. Yes!!! Everything we think about, process and learn is stored in our brains – short-term memory and long-term memory hippocampus.

Machines and Man work more or less akin to each other, If I could have two words to represent a Microcontroller, they will be Processor and Memory. And today we are gonna talk about Memory, especially Flash Memory.

In this article, let’s understand:

Introduction to Flash Memory

Flash memory is a long-life and non-volatile storage chip that is widely used in embedded systems. It can keep stored data and information even when the power is off. It can be electrically erased and reprogrammed. Flash memory was developed from EEPROM (electronically erasable programmable read-only memory). It must be erased before it can be rewritten with new data.

Types of Flash Memory

It can be classified based on the electrical circuit alignment within the semiconductor chip. That with a vertical alignment is called NAND flash, while that with a horizontal alignment is called NOR flash.

NOR was originally designed to replace ROM, EPROM, and EEPROM non-volatile memory.NAND was developed to achieve higher capacities, and smaller footprints when compared to NOR.
It has a full set of address lines which allows quick random access to any location in the memory array.It requires a relatively long initial read access to the memory array compared to that of NOR flash.
It is slower to erase and write new data.NAND is faster to erase and write.
It is more expensive because of larger cell size.Much smaller than NOR, and less expensive.
Individual bytes can be directly accessed.Individual bytes can’t be directly accessed.
As an analogy, NOR flash is like RAM.NAND flash is more like a Hard Disk.
NOR flash memory requires more current when it is first powered on, but requires less power for standby.NAND flash memory requires less power to start up, but more for standby power.
It is typically used for boot code storage and execution
as a replacement for the older EPROM and as an
alternative to certain kinds of ROM applications in embedded systems.
It’s suited for applications requiring low-cost, high-density, and fast erases.
  • In most of the Embedded Microcontroller devices, NOR flash is used because of its suitability in embedded applications.
  • NAND flash has several issues that make it unsuitable for program storage (NAND has to be accessed in blocks and has the bad habit of corrupting some of its data, so a management system is needed to keep track of blocks usage and of bad records).

Why do we need flash memory?

In microcontrollers, the flash memory is primarily used to store the program which is to be executed. Also, the application can use the flash memory as an easy replacement for an EEPROM ( Electrically Erasable Programmable Read Only Memory). Thereby, the flash memory can be used to store constant data the application needs when the device reboots.

Flash Memory Organization of STM32 devices

In this article, the STM32L452xx microcontroller is used for explanations. The STM32L452xx microcontroller consists of 512KB of flash storage. The flash memory is divided into 256 pages of 2KB each. The memory organization of STM32L452xx can be found by referring to the reference manual.

Page, Sector and Block

NOR memory is organized in various subdivisions or groups of bytes which delineate the minimum and maximum size as well as the address alignment of erase and program operations. 

Page < Sector < Bank < Block

Page or Sector Overview:

The concept is the same, between pages and sectors. STM32F7 documentation uses the sector term and STM32L4 uses page. Sectors are much bigger than the typical pages in external flash memory. The sector is most commonly 512 bytes, and Pages is 256 bytes.

Page is a partitioned unit of storage, Like a page in a Book It includes 2k word.

Block Overview:

Block is one level higher than the sector and it contains multiple sectors or pages. STM32L452xx devices feature up to 512 Kbyte of embedded flash memory available for storing programs and data in single-block architecture. The Flash memory contains 256 pages of 2 Kbyte.

Also, You may see some other nouns, such as – sector level Sub Sector, And block level Bank, etc.

I hope you enjoyed reading the article as much as I enjoyed writing it. 😁😁😁

Leave a Comment

Your email address will not be published.