Jump to content

what is the difference between Flash memory and SRAM.

Recommended Posts

Hello all,

I have few concepts which I need to clear! Please provide your important experience and knowledge.


I keep on reading different controllers with different ratings of flash memory and SRAM. MSP has FRAM.


1.  Usually flash memory is usually much larger than SRAM,  because of cheaper price?

2. I know that prog is stored in flash and variables in SRAM. But the variable can be stored in flash also. right?

3.  I know that FRAM is faster, less power consuming, longer life than flash.. Only MSP has this FRAM technology right?


I know that most of the ARM controllers today have modified Harvard architecture with separate data and instruction cache and separate data and instruction buses. Data and instructions in the same memory.


I want to clear some basic concepts.


thanks a lot.



Link to post
Share on other sites

Well i'll try to explain.


Flash is a non-volatile memory, meaning that it retains the memory stored even when you stop powering it. The RAM is volatile so it loses all the data store when you stop powering it. FRAM is a type of RAM but it retains the data even after power off.


Flash is the least expensive of the 3 so it's normally bigger and due to being non-volatile you use it to store the code and you can also save there data, like your HDD in your computer. Flash is also the slowest of them all and it has a life time, i think the MSP flash has about 100k erase-write cycles. Note that although flash is access and writing is much slower than a RAM it's faster than a HDD, it's like a SSD.


RAM is very fast and can be accessed tons of times without wearing out. It's volatile so you can't use it to save a permanent code, although you can save there code and run from there, if you power down the MCU then you lost all the code. It's more expensive than the flash hence the smaller size compared to Flash. It's the best to store variable since it's the fastest and that i necessary when doing math and other operations. 


FRAM is the most expensive of the 3. It can work as a Flash since it's non-volatile and you can use it as a RAM since it's so fast. It's faster, less power consuming and it lasts even longer than a RAM.

FRAM is also a RAM because RAM stands for random access memory. RAM doesn't exactly stand for a volatile memory although that is mostly the case.

I think MSP is the first micro controller with the FRAM 

Note that unlike the Flash the FRAM wears out even with just reading it while the Flash is just with erase and write. Also the FRAM is slower than SRAM is remember right. One big advantage i read up is that since it's so fast compared to Flash, you can execute a code quicker (you read it quicker) so you can then have the MCU in standby by a longer percentage of time, so it's good to save power

Link to post
Share on other sites

As I understand it erases "wear" a flash memory, I have not seen indication that writes do also.
(Of course between erases all you can write to a flash are 0 bits, so there is a practical limit to the number of meaningful writes you can do between erases).


On question 2.
Variables are not normally stored in flash (unlike RAM or FRAM you need a special procedure to write to flash, while a programming language could do that behind the scenes to allow variables to be stored in flash, this is not typically done.)
Constants on the other hand are typically stored in flash.

const int i = 3;  // Stored in flash
int j = 3; // Stored in RAM, but initial value stored in flash and copied to RAM by startup code.

You didn't ask, but just for completeness, the other kind of RAM you will encounter on Stellaris/Tiva processors is EEPROM.

(Electrically Erasable Programmable Read Only Memory).


Flash is a kind of EEPROM.  The EEPROMs on the Tiva processors are smaller than RAM.

They can typically be erased a word at a time (vs. Flash which is typically erased in blocks), and you do not have to explicitly erase before writing.

The EEPROM also has some protection mechanisms to control access to pages.

Other than that pretty similar to Flash (non-volatile, limited number of erasures, slower than RAM).


Typically used for storing configuration values (e.g. MAC or IP address for a network device)  (i.e. information that is changed occasionally but needs to be retained while the device is off).  Since it is in a separate address area one does not have to worry about not overwriting program data (as one would with storing values in Flash).



There is also a bit of ROM on the chip - holds built in libraries, etc.

Link to post
Share on other sites

many many thanks L.R.A and igor. both the posts have solved most of the doubts!

ok, so only we have:


static const  char myname[] ={"Vin"};


to keep the array in flash since we know that this variable is not intended to be changed in the prog.

and save some space on the RAM which is small.


If I get some doubt again, I will continue here.Thanks once again:-)




Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...