Arduino internal EEPROM

preview_player
Показать описание
1- EEPROM : Electrically Erasable Programmable Read-Only Memory, Ii is a non-volatile memory constructed using an array of floating-gate transistors, with two transistors per bit.

2- EEPROM limitations:

1) Write-cycles: is the limit number of times you can only write or rewrite the data and it is about 100000 to 2 millions write-cycles.
but you can read from it as much as you want.

2) Retention time: is the time that EEPROM can retain data before it becomes corrupted, it is about 10 years.

3) Storage capacity: it is quite small compared to other memory devices. USeful for apps that require calibration, or storage of user's parameters.

----------------------------------------------------------------------------
| Arduino MCU | EEPROM capacity |
----------------------------------------------------------------------------
| Armega2560 (Mega) | 4096 Bytes |
----------------------------------------------------------------------------
| Atmega328 (UNO, MINI) | 1024 Bytes |
----------------------------------------------------------------------------
| Atmega168 (NANO) | 512 Bytes |
----------------------------------------------------------------------------
3- EEPROM Functions:
this technique is called "wear levelling".
Here is the code:
#include EEPROM.h
int address_val= 10;
short val=32000;
void setup() {
save_to_eeprom (address_val,val);
int val_read=read_from_eeprom (address_val);
}
void loop(){
}

void save_to_eeprom (int address,short value) {
EEPROM.update( address, (value !!));
//value shifted to right by 8
EEPROM.update( address+1, (value & 0xff) );
}

int read_from_eeprom (int address) {
return (EEPROM.read(address)!!)+EEPROM.read(address+1);
// value-MSB shifted to left by 8
}
Рекомендации по теме