Arduino Forum

Using Arduino => Microcontrollers => Topic started by: Vincent19 on Nov 09, 2012, 05:32 pm

Title: Difference between EEPROM and flash memory
Post by: Vincent19 on Nov 09, 2012, 05:32 pm
Hey there,

I have a confusion here actually.

What's the difference between EEPROM and flash memory of a chip ?

Thank you
Title: Re: Difference between EEPROM and flash memory
Post by: Grumpy_Mike on Nov 09, 2012, 05:59 pm
In the arduino flash memory is the place where the program is stored and EEPROM is just for non volatile data.
In general flash is quicker to read from, the both take a bit of time to write to.
Title: Re: Difference between EEPROM and flash memory
Post by: Vincent19 on Nov 09, 2012, 06:05 pm
so what for i have to expand the eeprom storage?
Title: Re: Difference between EEPROM and flash memory
Post by: Grumpy_Mike on Nov 09, 2012, 06:08 pm
English a bit bad on that.

It is rare that you would want to expand EEPROM memory, but for example I have used external chips to store a look up wave table.
For most projects you would not even use the EEPROM.
Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 09, 2012, 06:10 pm

so what for i have to expand the eeprom storage?


Most people use SD cards when they need more storage.

Title: Re: Difference between EEPROM and flash memory
Post by: Vincent19 on Nov 09, 2012, 06:14 pm
So normally we expand the flash memory only?
Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 09, 2012, 06:32 pm

So normally we expand the flash memory only?


The internal memory on the Arduino can't be expanded. If you need more you have to use an Arduino Mega.
Title: Re: Difference between EEPROM and flash memory
Post by: Grumpy_Mike on Nov 09, 2012, 08:33 pm
There is no way to expand any memory on an Arduino.
On the mega you can expand the SRAM with a card but that is all.

All other forms of memory expansion is what it known as paged memory. It does not appear in the memory map, you can't use it for program storage or variables, only for storing data through port bit manipulation.

What do you want to expand and why?
Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 09, 2012, 09:11 pm
I may jump in here, if I may, as I was about to start a thread asking a question that has come about in the last few replies. I'm working on a project at the moment that will ultimately need multiple large look up tables. 4 or 5 tables of 15 x 10 values for example.

1) Look up tables are stored in EEPROM yes? If so, I can expand the amount of EEPROM I have by adding an external EEPROM chip?

2) Regarding SRAM, if I understand correctly - this type of memory is used up quickly when performing float calculations, doing serial strings etc - can one also expand SRAM with an external chip? Currently I'm using a 1284P, so have quite an abundance of SRAM - however, I/O requirements may see me needing to up to a 2560 chip.
Title: Re: Difference between EEPROM and flash memory
Post by: CrossRoads on Nov 09, 2012, 09:18 pm
Static Lookup tables are typically stored in PROGMEM. EEPROM is generally used when the sketch needs to make changes that need to be stored.

You can add external EEPROM & SRAM. FRAM is another option - writes fast like SRAM, has EEPROM non-volatility.  All are available in little 8-pin packages with serial interface.


Title: Re: Difference between EEPROM and flash memory
Post by: Grumpy_Mike on Nov 09, 2012, 09:20 pm
Quote
1) Look up tables are stored in EEPROM yes? I

They can be if you want, although you have some EEPROM built in. They could also be stored in Flash if they are static, that is if they don't change.

Quote
I can expand the amount of EEPROM I have by adding an external EEPROM chip?

Yes, well you don't expand the internal stuff you just have an external I2C chip.

Quote
this type of memory is used up quickly when performing float calculations

No floating point makes little difference to the SDRM usage.

Quote
can one also expand SRAM with an external chip?

Extra memory shield for the Mega
http://www.ruggedcircuits.com/html/megaram.html (http://www.ruggedcircuits.com/html/megaram.html)

Quote
I/O requirements may see me needing to up to a 2560 chip.

Shame, there are many ways to increase I/O without going to a bigger processor, just use a port expander.
Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 09, 2012, 09:49 pm
I see - thank you for input thus far. I will take a look at port expanding, it doesn't sound like it should be too much of an issue as I only need more general purpose I/O, for things like low rate sensor sampling.

The look up tables are static yes, if they need to be changed - then it's a reflash job, there are slight modifiers to these values, adders and multipliers and what not - but that's temporary stuff that is stored in RAM yes?

Now I know I can up my I/O this way - sticking with the 1284, with it's large amount of RAM - I need not worry about adding external. Maybe just external EEPROM to allow for a bit of future flexibility in the PCB.
Title: Re: Difference between EEPROM and flash memory
Post by: Grumpy_Mike on Nov 09, 2012, 09:55 pm
Quote
but that's temporary stuff that is stored in RAM yes?

Yes.

Look at the MCP23S17 it is one I use a lot, it uses the SPI bus or the MCP23017 that uses the I2C bus.
They give you 16 I/O per chip and you can have 8 chips on each bus.
Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 09, 2012, 09:59 pm
Wow - that's just opened a lot of doors for me, thanks so much for the recommendation. I'll check them out now. This is all a very steep learning curve for me, that is only getting more and more enjoyable :D

EDIT: I'm just looking at things like data rates - but any preferences of I2C vs SPI? I've only used SPI for ICSP before, and I2C for a few temp sensors. I have chosen SPI as the bandwidth is FAR higher.

On another note, any recommendations for external serial EEPROM chips people have successfully used? Also, what's the bit value talking about here? For example, microchip offer them in 128bit, 1kbit, 2, 4, 8 etc...
Title: Re: Difference between EEPROM and flash memory
Post by: Vincent19 on Nov 10, 2012, 05:32 am
So, how can I expand the IO pins in arduino UNO ?
Title: Re: Difference between EEPROM and flash memory
Post by: CrossRoads on Nov 10, 2012, 06:29 am
jtw11, how much memory do you need, and how often will you use it?
I'd go with this.
http://www.mouser.com/ProductDetail/Ramtron/FM25640B-G/?qs=sGAEpiMZZMtsPi73Z94q0LVCZPBibhMGLoJvNRrGMO0%3d
64K, SPI, 5V operation. Doesn't have 3.3mS write times like EEPROM, you'll never wear it out.

Vincent19,
Connect up the Arduino ICSP header to the SPI port (lower left) on a board like this, and bring over the additional CS and INT pins from D2-3-4 or wherever.
http://www.mouser.com/ProductDetail/mikroElektronika/MIKROE-127/?qs=%2fha2pyFaduhRbLyvlpnF2i%252bszNIaZu4g3TBVIiMroqnC%2fuqCSuPFAg%3d%3d
Probably a library for this chip somewhere too.
http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf

Available in DIP package also
28-pin PDIP (300 mil)
http://www.digikey.com/product-detail/en/MCP23S17-E%2FSP/MCP23S17-E%2FSP-ND/894276
Title: Re: Difference between EEPROM and flash memory
Post by: Grumpy_Mike on Nov 10, 2012, 09:23 am

So, how can I expand the IO pins in arduino UNO ?

Lots of ways.
Look at this project of mine, if you down load the schematics there are versions both with and without port expansion.

http://www.thebox.myzen.co.uk/Hardware/Pendulum.html (http://www.thebox.myzen.co.uk/Hardware/Pendulum.html)
Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 10, 2012, 01:23 pm

I may jump in here, if I may, as I was about to start a thread asking a question that has come about in the last few replies. I'm working on a project at the moment that will ultimately need multiple large look up tables. 4 or 5 tables of 15 x 10 values for example.


That's hardly massive...should fit in progmem.


1) Look up tables are stored in EEPROM yes? If so, I can expand the amount of EEPROM I have by adding an external EEPROM chip?

2) Regarding SRAM, if I understand correctly - this type of memory is used up quickly when performing float calculations, doing serial strings etc - can one also expand SRAM with an external chip? Currently I'm using a 1284P, so have quite an abundance of SRAM - however, I/O requirements may see me needing to up to a 2560 chip.


It all depends on how fast/often you need to look things up...and if you need to write data as well as read it.

There's a lot of 8-pin flash memory chips out there with SPI interfaces of you're mostly reading data.

SRAM is only needed if you're writing/updating the data a lot.

EEPROM is somewhere between the two.

First though, you have to define your speed requirements.
Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 10, 2012, 10:02 pm
It seems then extra RAM is the best option - as I'm reading static values from flash stored by PROGMEM, but than altering them as mentioned with terms such as adders and multipliers, and thus are stored in RAM. Right now, there's no way I've run out of RAM - but future code may do when processing many many more terms at once, so best add it to the hardware now.

These values in RAM are being updated on average, once each mS, sometimes twice as fast. Sounds like EEPROM is FAR too slow here.
Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 10, 2012, 10:10 pm

It seems then extra RAM is the best option - as I'm reading static values from flash stored by PROGMEM, but than altering them as mentioned with terms such as adders and multipliers, and thus are stored in RAM. Right now, there's no way I've run out of RAM - but future code may do when processing many many more terms at once, so best add it to the hardware now.

These values in RAM are being updated on average, once each mS, sometimes twice as fast.


Sounds like you need an SRAM chip with SPI interface. You can get them in little 8-pin chips.

Sounds like EEPROM is FAR too slow here.


The onboard EEPROM take about 1ms to write a single byte. I can't imagine external EEPROMS will be any better.

Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 10, 2012, 10:17 pm
Quote
Sounds like you need an SRAM chip with SPI interface. You can get them in little 8-pin chips.


Yep, just reading about these chips recommended by Crossroads - http://uk.mouser.com/ProductDetail/Ramtron/FM25640B-G/?qs=sGAEpiMZZMtsPi73Z94q0LVCZPBibhMGLoJvNRrGMO0=
Title: Re: Difference between EEPROM and flash memory
Post by: CrossRoads on Nov 11, 2012, 12:51 am
"The onboard EEPROM take about 1ms to write a single byte."
No, EEPROM takes 3.3mS.

The FRAM is nice because it stores data like an EEPROM, but at SRAM speeds.
FRAM/EEPROM only needed if you need to keep the data between resets or loss of power.
Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 11, 2012, 11:26 am
Volatility is not an issue - there is no problem with the RAM being erased when the power is lost in my application.

In which case, is there any advantage of FRAM over SRAM? Seems FRAM has very fast write speeds (or lack of!). I am also writing a lot to an SD card and thus will need to buffer lots of data in RAM until its written.
Title: Re: Difference between EEPROM and flash memory
Post by: silasmoeckel on Nov 11, 2012, 04:38 pm

Volatility is not an issue - there is no problem with the RAM being erased when the power is lost in my application.

In which case, is there any advantage of FRAM over SRAM? Seems FRAM has very fast write speeds (or lack of!). I am also writing a lot to an SD card and thus will need to buffer lots of data in RAM until its written.


FRAM does not need power to retain the data.  As you say volatility is not an issue you probably do not need to use it.  Neither will really help you in regards to writing data to a SD card that needs to be internal SRAM and since it's block oriented it's uses a 512b buffer. 

Please note that your going to end up coping everything to and from internal sram constantly so your not necessarily during yourself a favor trying to use offboard sram. 
Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 11, 2012, 05:51 pm
Quote
Please note that your going to end up coping everything to and from internal sram constantly so your not necessarily during yourself a favor trying to use offboard sram.


I see - in which case, what ever is the point in using external RAM? It seems that statement renders it useless. Then again, a PCs RAM is all external minus the small cache?

Futhur, I started a thread in the storage section - as I was looking at using SD cards to store logged data, however - could I use an external flash IC for this? Is there a library, or is it possible to do this?
Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 11, 2012, 06:04 pm

Futhur, I started a thread in the storage section - as I was looking at using SD cards to store logged data, however - could I use an external flash IC for this?


Definitely.


Is there a library, or is it possible to do this?


I assume the SD libary has a function to read/write a disk sector. Hack that to use the flash/RAM chip instead and ... bingo!

Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 11, 2012, 06:22 pm
Just looking at the flash chips available - I have found an SPI flash IC (good, easier to adapt to the SD library being SPI I assume) of 32mb. It seems this is an appropriate sort of chip?

I'm just planning to design something like this into the hardware for future use.

http://uk.farnell.com/spansion/s25fl256sagnfi001/memory-flash-256mbit-8wson/dp/2136254
Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 11, 2012, 06:39 pm

Just looking at the flash chips available - I have found an SPI flash IC (good, easier to adapt to the SD library being SPI I assume) of 32mb. It seems this is an appropriate sort of chip?

I'm just planning to design something like this into the hardware for future use.

http://uk.farnell.com/spansion/s25fl256sagnfi001/memory-flash-256mbit-8wson/dp/2136254


Yep. Something like that....

That one has 16 pins for some reason, most of them have 8. Try restricting the Farnell search to 8 pin chips, they should be much cheaper...

Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 11, 2012, 06:41 pm
I think it's just the picture - it's listed as 8 pins. The datasheet won't load - the microwave is on see, of which my router is cleverly sat next to. Long story.  8)
Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 11, 2012, 06:43 pm
One other thing... You won't be sticking that chip into a PC card reader so you might not even need FAT file system support (depending on your data). eg. For a simple data log you can just start at the beginning and fill it up.


Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 11, 2012, 06:45 pm

I think it's just the picture - it's listed as 8 pins. The datasheet won't load - the microwave is on see, of which my router is cleverly sat next to. Long story.  8)


I loaded the datasheet and it was 16...

Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 11, 2012, 06:47 pm
Quote
I loaded the datasheet and it was 16...
Ah - I'll continue the search.

Why the point re FAT file systems? Does the SD library use it? I haven't yet used the library?
Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 11, 2012, 06:49 pm

Why the point re FAT file systems? Does the SD library use it?


Yes.
Title: Re: Difference between EEPROM and flash memory
Post by: CrossRoads on Nov 11, 2012, 06:51 pm
http://uk.farnell.com/spansion/s25fl256sagnfi001/memory-flash-256mbit-8wson/dp/2136254

That part is a type of Flash memory, not SRAM. It does have 16 pins.

Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 11, 2012, 06:52 pm
Crossroads, we've got on to talking about using external flash to store logged data as opposed to SD cards.
Title: Re: Difference between EEPROM and flash memory
Post by: CrossRoads on Nov 11, 2012, 06:57 pm
That chip would hold a lot then.
Title: Re: Difference between EEPROM and flash memory
Post by: fungus on Nov 11, 2012, 07:15 pm

Crossroads, we've got on to talking about using external flash to store logged data as opposed to SD cards.


I just remembered you were talking about storing data tables in there. It's easy to use fixed addresses in the memory chip for that sort of thing instead of going through all the layers of FAT (hah...I made a pun!)

Title: Re: Difference between EEPROM and flash memory
Post by: CrossRoads on Nov 11, 2012, 07:26 pm
I could agree with that. Easy to control where you're accessing.
Title: Re: Difference between EEPROM and flash memory
Post by: jtw11 on Nov 11, 2012, 11:11 pm
For those lookup tables as part of my code, I'm happy to save these in the onboard flash using PROGMEM. I plan to use this external flash for logged data, but looks like I need to do some reading up on file systems, how to address certain bits of the flash etc etc. Any good reading links?

Going back to the quoted comment below, I do not follow the logic?


Please note that your going to end up coping everything to and from internal sram constantly so your not necessarily during yourself a favor trying to use offboard sram. 


Surely that's not particularly a problem, as I mentioned before - PCs for example use external RAM. Surely it's better to copy to external RAM, than to not and then run out of internal RAM?