Can someone explain "flash" memory to me ?

I saw this syntax for the Serial.print () command and I don't understand what it means re flash memory.
To me the variable "Hello World", is created in the programs(sketch) memory, the 1st time the compiler encounters it.
To me memory is memory and the bit about flash memory is not clear.
If I were to leave the "F" off as in
Serial.print("Hello World")
What difference does that make in how the program (sketch) allocates memory ?

thanks

This code is from the reference manual.

You can pass flash-memory based strings to Serial.print() by wrapping them with F(). For example:

Serial.print(F("Hello World"))

F()

arduino flash memory

Time to do some reading:

https://www.arduino.cc/en/tutorial/memory

"To me memory is memory "

then you are not understanding the 3 types available (sizes are for a 328P based board):

  • flash, the 32 kbytes where the bootloader and your sketch is stored. Nonvolatile, saved thru a power loss. Sketch runs again when power is restored or after a reset. May be written if "special" code is added to the bootloader to let the sketch make calls to the bootloader sketch to rewrite parts of the flash. (process documented in the past, I've lost the bookmark to that forum topic).
    Found it: https://forum.arduino.cc/index.php?topic=332191.0

  • SRAM, the 2 kbytes where are the variables and registers that are manipulated as part the sketch operation are stored. Volatile, not saved thru a power loss.

  • EEPROM, the 1 kybtes of non-volatile memory where the sketch can save information and is retained thru loss of power (depending on one of the fuse settings).

Adafruit has a great article on the memory types here, see page 21 on F() for putting things in flash.

1. Fig-1 depicts the three types of memory space available within ATmega328P MCU.
memSpacex.png
Figure-1:

2. Usually, the variables are stored in the RAM memory of SRAM space, which is only 2x1024 bytes. For example:

char myMsg[] = "Hello World";
Serial.print(myMsg);

3. The Flash Memory/Code Memory/Program Memory is 32x1024 bytes. The MCU architecture allows of storing/retrieving some data into flash for which there are special instructions like LPM (Load Program Memory) and SPM (Store Program Memory). A programmer can save some RAM space by storing constant data (like welcome message) into flash. For example:

Serial.print(F("Hello World"));

4. F stands for (probably!) for flash, and it somehow implements the LPM and SPM instructions.

Why is it called flash memory?

memSpacex.png

"Flash was originally developed by Toshiba electrical engineer Fujio Masuoka, who filed US Patent 4,531,203 on the idea with colleague Hisakazu Iizuka back in 1981. Originally known as simultaneously erasable EEPROM (Electrically Erasable Programmable Read-Only Memory), it earned the nickname "flash" because it could be instantly erased and reprogrammed—as fast as a camera flash. At that time, state-of-the-art erasable memory chips (ordinary EPROMS) took 20 minutes or so to wipe for reuse with a beam of ultraviolet light, which meant they needed expensive, light-transparent packaging. Cheaper, electrically erasable EPROMS did exist, but used a bulkier and less efficient design that required two transistors to store each bit of information. Flash memory solved these problems."

CrossRoads:
[...]Originally known as simultaneously erasable EEPROM (Electrically Erasable Programmable Read-Only Memory), [...].

Is EEPROM not the abbreviation for: "Electrically Erasable Electrically Programmable Random Access Read-Only Memory"?

GolamMostafa:
Is EEPROM not the abbreviation for: "Electrically Erasable Electrically Programmable Random Access Read-Only Memory"?

Not sure; if you think it is then maybe correct the WikiPedia page;

"EEPROM (also E2PROM) stands for electrically erasable programmable read-only memory"

GolamMostafa:
Is EEPROM not the abbreviation for: "Electrically Erasable Electrically Programmable Random Access Read-Only Memory"?

Yes. Common usage is that EEPROM can be erased at a byte level while Flash is erased at a block level, though Flash, like EEPROM, is electrically eraseable, programmable, random access, read only (in the sense that it is non-volatile when power is removed) memory.

From an implementation perspective Flash is denser than EEPROM (fewer transistors per bit), so the application space for each is driven by which is the more important characteristic. For microcontroller program space, erasing a block and rewriting isn't a big deal since a newly compiled program typically changes a lot of bytes anyway. For persistent application memory having to erase a block and rewrite to change a single byte is typically a disadvantage because of the time required to do so, thus EEPROM is advantageous for this usage.

GolamMostafa:
Is EEPROM not the abbreviation for: "Electrically Erasable Electrically Programmable Random Access Read-Only Memory"?

Isn't the second "electrically" redundant? (And the "random access")
It's not like you have to chisel-in the new bits.

srnet:
"EEPROM (also E2PROM) stands for electrically erasable programmable read-only memory"

EEPROM is seen to have this style E2PROM and not E2PROM.

TheMemberFormerlyKnownAsAWOL:
Isn't the second "electrically" redundant? (And the "random access")
It's not like you have to chisel-in the new bits.

It is like AC Current; where, Current is certainly redundant; but, it is needed to maintain the flow of voice.

For sure, "random access" is not redundant.

There's some history to this... first there was RAM, then ROM then PROM then EEPROM. Each acronym was kept backwards compatible. :slight_smile: RAM went to FRAM and NVRAM for example.

aarg:
There's some history to this... first there was RAM, then ROM then PROM then EEPROM. Each acronym was kept backwards compatible. :slight_smile: RAM went to FRAM and NVRAM for example.

Are RAM, ROM, PROM, EEPROM acronyms or abbreviations?

An acronym has been defined as a noun word which is formed by taking the initial letters of every word of a title. Thus: WHO is an acronym for "World Health Organization".

An Abbreviation has been defined as a noun word which is taken as a short for a relatively big title. Thus: RAM is the abbreviation for "Random Access Read and Write Memory".

Acronym vs initialism.

Tough one - in the UK for example, NATO is an acronym (we say "nay-toe"), but WHO is an initialism (we say "double-you-aitch-oh", not "who")

WHO
who.png

who.png

Pronounced, in the UK "double-you-aitch-oh", not "who" as in "Dr Who"

When a school boy in UK is asked to write the full name of WHO, what does he write on paper?

"World Health Organisation"

Who’s (Whose) on first?
I dunno.

Don’t forget EPROM, EAROM, UVEPROM and the many others.