Microcontroller eliminates offboard EEPROM with "virtual-EEPROM" routines
Wallace Ly, National Semiconductor Corp, Santa Clara, CA -- EDN, May 10, 2001
COP8flash µCs let you allocate some of their internal flash memory as a nonvolatile storage space. This line of flash µCs accomplishes this task by accessing some memory functions built into the boot ROM. In addition to some of these memory functions, the COP8flash µC can initiate and control in-system programming under software. You can use 'virtual EEPROM,' although not truly EEPROM, to mimic the behavior of the storage space of an offboard EEPROM. Note that the flash inside the COP8flash µC is not just renamed E2. This fact has significant implications because the flash µC is rated for 100,000 erase/write cycles and 100-year data retention.
Figure 1 depicts how you can allocate a 128-byte virtual EEPROM. Although users may not write over the same byte twice, they may modify RAM contents. Additionally, you can 'shadow' the flash µC with RAM. If users want to permanently save the contents of the virtual EEPROM, then they may execute a 'flush' to dump the contents of the modified RAM into the flash µC.
A system designer may bring up the issue that the 'dumping' of the RAM into the flash µC may take too long. However, the opposite is true if you take the following into consideration: A typical write to the flash µC takes a few microseconds, and a page erase takes 8 msec, independently of the µC system clock. So, the dumping process may take less than 10 msec. However, a designer is hard-pressed to find an offboard serial EEPROM that has less than 100 msec of access time.
Figure 2 shows how to visualize the sample virtual-EEPROM code. As you shadow the flash µC, you write bytes to the RAM, and a WRITE_COUNTER decrements. When the WRITE_COUNTER equals 0, the routine flushes the contents of the RAM. The flash µC then saves the contents of the RAM. A system designer can set the WRITE_COUNTER to 0 to immediately copy the contents of the RAM into the flash µC. Click here to download the Virtual EEPROM C code.


















