28.2.2 Memory Layout

A single logical EEPROM page is physically stored as the page contents and a header inside a single physical FLASH page, as shown in Figure 28-2.

Figure 28-2. Internal Layout of An Emulated EEPROM Page
Within the EEPROM memory reservation section at the top of the NVM memory space, this emulator will produce the layout as shown in Figure 28-3 when initialized for the first time.
Figure 28-3. Initial Physical Layout of The Emulated EEPROM Memory
When an EEPROM page needs to be committed to physical memory, the next free FLASH page in the same row will be chosen - this makes recovery simple, as the right-most version of a logical page in a row is considered the most current. With four pages to a physical NVM row, this allows for up to three updates to the same logical page to be made before an erase is needed. Figure 28-4 shows the result of the user writing an updated version of logical EEPROM page N-1 to the physical memory.
Figure 28-4. First Write to Logical EEPROM Page N-1
A second write of the same logical EEPROM page results in the layout shown in Figure 28-5.
Figure 28-5. Second Write to Logical EEPROM Page N-1
A third write of the same logical page requires that the EEPROM emulator erase the row, as it has become full. Prior to this, the contents of the unmodified page in the same row as the page being updated will be copied into the spare row, along with the new version of the page being updated. The old (full) row is then erased, resulting in the layout shown in Figure 28-6.
Figure 28-6. Third Write to Logical EEPROM Page N-1