Non-Volatile Memory (Part 2): EEPROM in ATmega

Опубликовано: 04 Август 2026
на канале: Arduino under the Hood
23
1

📥 RESOURCES & DOWNLOADS
• avr/eeprom.h: EEPROM handling: https://www.nongnu.org/avr-libc/user-...
• Practical Example
– eeprom_init.zip: https://drive.google.com/file/d/1NGAw...

✏️ EXERCISES
• Internal Temperature Sensor Calibration Data stored in the EEPROM https://drive.google.com/drive/folder...

🧠 QUIZ
https://forms.gle/V6NZ6DVPGo7Mgi1o6

Have you ever needed to store configuration data, calibration values, or large constants that survive power cycles? In this comprehensive section, we explore the non-volatile memory options in the ATmega328P - the 32KB Flash memory and 1KB EEPROM. You will learn how to store large read-only data in Flash to save precious SRAM, and how to persist runtime data in EEPROM that survives resets.

EEPROM provides simpler persistent storage: 1KB byte-addressable memory with 100,000 write cycles (10x more than Flash). No page organization means any byte can be written independently. Three registers control access: EEAR (address), EEDR (data), and EECR (control with EEMPE, EEPE, EERE bits).

The EEPROM write sequence is security-protected: set EEMPE, then set EEPE within 4 clock cycles, otherwise the write aborts. This prevents accidental writes from errant code. AVR-libc provides eeprom_read_byte() and eeprom_write_byte() functions that handle the timing requirements.

EEPROM initialization and wear-leveling considerations are discussed: checking if EEPROM contains valid data (using magic numbers), initializing on first boot, and strategies for extending EEPROM life when storing frequently-changing values.

#Arduino #ATmega #EEPROM #NonVolatile #PersistentStorage #EmbeddedSystems #MemoryManagement #DataStorage

📖 CHAPTERS
0:00 Introduction
1:10 Configuration Registers for the EEPROM
4:36 Sequence of Configurations
6:09 EEPROM Support in the AVR Library
8:30 EEPROM Access Timings
9:45 How to access the EEPROM?
12:38 Practical Example
23:23 Summary and What's next?