The datasheet for the ATmega328P contains this table, which describes bits 4 and 5 of EECR:
|0||0||3.4ms||Erase and write in one operation (atomic operation)|
I'm currently working on some non-blocking EEPROM-handling code and I'm wondering when and how I should erase the EEPROM.
- What does erasing do? Does it set one byte to 0x0, or the entire EEPROM?
- Should I erase it first whenever I want to write a byte?
- If not, why is there an option to erase and write separately?
- How do I initiate an erase?
Either the datasheet is rather lacking concerning the EEPROM, or I'm just not finding what I'm looking for. I tried using a search engine, but all results are either about the Arduino EEPROM library or <avr/eeprom.h>, both of which use polling instead of interrupts (and are therefore blocking).