If it's using Read-Only Memory (ROM) then how am I able to write to it?
Best Answer
The EEPROM acronym has some history which follows the development of the technology.
ROM: Read-Only Memory. Written at the factory.
PROM: Programmable Read-Only Memory but programmable (once) by the user. Really a one-time programmable, forever readable memory. Get it wrong and you dump the chip.
EPROM: Eraseable Programmable Read-Only Memory. Usually erased using UV light through a quartz window above the chip. A bit of trouble but very useful.
EEPROM: Electrically Erasable Programmable Read-Only Memory. Can be erased or re-written under program control.
Figure 1. An Intel 1702A EPROM, one of the earliest EPROM types, 256 by 8 bit. The small quartz window admits UV light for erasure. Source: Wikipedia EPROM.
So, I hear you say, why do they call it eepROm when it is writeable? The answer to this is, I suspect, that, unlike RAM (random access memory) it holds its contents during power cycle and, therefore, behaved more like a ROM.
First, according to the data sheet, a erase-write-cycle takes at least 0.8ms, and up to 2.6ms. You say that you have an interrupt every 1ms, which may lead to a write operation. I have seen in the code that you disable interrupts for parts of the erase and for parts of the write function. But you still might get funny interleaving of the function calls. Maybe it helps when you disable interrupts for the whole sequence of erase and write?
Second - you might want to write while to power goes down, and the EEPROM write happens exactly in the moment when the supply voltage goes below the operating voltage. You can try to monitor the supply voltage, and refuse a write when it is below, lets say, 4.5V. This assumes that it stays long enough above 2.7V as the minimal operating voltage, and brown-out-detection is set to trigger only below that point.
To be pedantic, FLASH memory is merely a form of EEPROM: There is a marketing / branding aspect here. Typically, the distinction used today is that EEPROMS are single-byte (or storage word) erasable / rewritable, while FLASH is block-based for erase/write operations.
Relevant to the question:
EEPROMs continue to be popular due to maximum erase/write cycle ratings being an order of magnitude or two better than FLASH
Due to investments in design typically having been amortized over time, as with any mature technology, the cost of production and testing reduces compared to a newer technology.
Best Answer
The EEPROM acronym has some history which follows the development of the technology.
ROM: Read-Only Memory. Written at the factory.
PROM: Programmable Read-Only Memory but programmable (once) by the user. Really a one-time programmable, forever readable memory. Get it wrong and you dump the chip.
EPROM: Eraseable Programmable Read-Only Memory. Usually erased using UV light through a quartz window above the chip. A bit of trouble but very useful.
EEPROM: Electrically Erasable Programmable Read-Only Memory. Can be erased or re-written under program control.
Figure 1. An Intel 1702A EPROM, one of the earliest EPROM types, 256 by 8 bit. The small quartz window admits UV light for erasure. Source: Wikipedia EPROM.
So, I hear you say, why do they call it eepROm when it is writeable? The answer to this is, I suspect, that, unlike RAM (random access memory) it holds its contents during power cycle and, therefore, behaved more like a ROM.