microcontroller - MEMORY MANAGEMENT

Micro-controller (MCU) uses variety of memories, which are in-built.  The size and purpose varies while execution of the program.


RAM (Random Access Memory) : RAM is a volatile memory, which will be lost or reset when power is lost or Reset button of the MCU is pressed.  The total RAM is logically subdivided into three parts. 

The first part may be used used for accumulators, stack pointer, various address points used by the ALU (Arithmetic and Logic Unit) and control system.

The next part may be used for storing system process values, registers, status, flags used by control system.

The left out part is the actual RAM used for the program variables.

ROM (Read Only Memory ) : The ROM is non-volatile memory, means the data in the ROM will not be lost on power loss, unless overwritten by the programmer. 


The ROM is called FLASH MEMORY in micro-controllers.  The Flash memory is logically divided into two parts.

The main part of Flash Memory is allocated tor the application program in binary code, which is loaded directly through the programmer.  Some micro-controllers have option to lock the reading of the flash memory for protecting from copying by others. 

A small part of the Flash Memory is earmarked to save booting code or booting sequence at one of the extremes.


EEPROM ( Elelctrically Erasable and Programmable Read Only Memory ) : This is also a ROM, but, it is used only to save variables either through the program or directly through the programmer.  This is also non-volatile program.  The values can be altered, if required, by the program.  The EEPROM is useful to save settings, parameters which can be changed by the user while MCU is processing/working.


Almost all compilers display the summary of actual Flash memory and RAM used for the program after compiling the code, which is useful to proper selection of Micro-controller (MCU).