Memory in Embedded Systems "part1"
Memory in general is broadly classified as read-only memory (ROM also Known as Code Memory) or random-access memory (RAM - Known As Data Memory). These two types behave differently, and each has its own set of merits and demerits.
(1) ROM
Read Only Memory is non-volatile memory ( wont be erased when powered down ) used for storing Program information and Permanent data which is called The Code Memory.
ROM Have a lot of Different Types ( MROM - PROM - EPROM - EEPROM ) , But Mostly nowadays in Embedded System Controllers Flash is used to store programs , EEPROM for Permanent data.
But what is a Flash Memory ?
Flash memory is a hybrid of ROM and RAM, inheriting the best features of both types of memories. it's driven by low cost , it's electrically programmable, fast to read from, and nonvolatile. Flash memory is usually stacked as sectors and can be erased only as sectors.
FLASH / EEPROM merits:
(1) Volatility :
it's not Volatile ( it can keep the Code , Data when Having a Power loss ).
FLASH / EEPROM Demerits :
(1) Speed:
The Main Demerit of The EEPROM is the Speed it's Slow To Read/Write From on the Other Hand Flash is Fast To Read From but slow to Erase , Write it.
(2) Endurance Problem :
" Flash & EEPROM Memory cannot Be reprogrammed for Ever. Acutely They cannot be Erased After Being erased for a number of Time mostly EEPROM , FLASH would have 10k - 100k Erase\Write Cycles.
in The Same Microcontroller Mostly EEPROM Read/Write Cycles will be More than flash as EEPROM is Used to Store Data Which Could be changed at any time in the Program.
(3)Data Retention Problem :
Data retention is the ability to retain its programmed state, and it's known to degrade over temperature.
Code Memory Map:
Code Memory is Mostly placed in Flash Which is Runtime Read-only memory.
The Mapping of The Code Memory Map is illustrated in The Following Figure.
- intvects
Contain The ISR Address , The First Place in this Segment will probably contain The REST interrupt address which holds the startup code.
2. .text
Contains All Your Written Software Code ( Main Code , Functions Code , ISR). This Segment is usually the Largest Segment.
3. .Switch:
Contain Tables for switch instructions.
4. .const
Contain the Read only Data ( Global and static string literals ).
5. .cinit
Contain the Initialized global and static variables values.
6. .pinit
Contains Initial values for C++ constructors .
7. .bootloader
if A Bootloader exist in your Application , this Section will Hold the Bootloader Code.
Will Talk About The RAM Segment in Part 2.