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"))
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.
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.
"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."
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.
There's some history to this... first there was RAM, then ROM then PROM then EEPROM. Each acronym was kept backwards compatible. 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. 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".