25.6.8.6 Writing and Reading the SmartEEPROM

SEESTAT.LOCK must be ‘0’; otherwise, writes are discarded and a hardfault exception is thrown. SmartEEPROM write access can be locked with the LSEE command and unlocked with the USEE command.
  1. Configure SBLK and PSZ fuses to define the SmartEEPROM total size and size of each page.
  2. Define a pointer to the SmartEEPROM area. It can be used for 8-, 16- or 32-bit access.
    volatile uint8_t *SmartEEPROM8 = (uint8_t *) SMEEPROM_ADDR; volatile uint16_t *SmartEEPROM16 = (uint16_t *) SMEEPROM_ADDR; volatile uint32_t *SmartEEPROM32 = (uint32_t *) SMEEPROM_ADDR;
  3. Wait until SmartEEPROM is busy.
    while (NVMCTRL->SEESTAT.bit.BUSY);
  4. Write to the SmartEEPROM like writing a RAM location. Perform an 8-, 16- or 32-bit write.
  5. If automatic reallocation is disabled with SEECFG.APRDIS, check the SEESFULL interrupt flag to ensure that the active SmartEEPROM sector is not full.
  6. To read back the content, read the location using the defined pointer.
    uint8_t eep_data_8 = 0; while (NVMCTRL->SEESTAT.bit.BUSY); eep_data_8 = SmartEEPROM8[0];
There are two NVM pagebuffer management modes available, selected by writing the SEECFG.WMODE bit field:
  • UNBUFFERED (default): WP command triggered after any pagebuffer update
  • BUFFERED: WP command triggered only in case of NVM page crossing. This mode increases the NVM wear-leveling but is more sensitive to power loss. SEESTAT.LOAD is high when the pagebuffer contains unwritten data.

When SEECFG.WMODE selects the buffered mode, the page buffer can contain unwritten SmartEEPROM data. This is reflected by SEESTAT.LOAD. To flush the SmartEEPROM data inside the page buffer, issue the SEEFLUSH command.

INTFLAG.SEEWRC indicates when a AHB write to the SmartEEPROM has completed:

  1. Unbuffered mode: AHB write has completed, NVM is programmed with correct values except if INTFLAG.SEESOVF was thrown.
  2. Buffered mode: AHB write has completed,
    • if SEESTAT.LOAD = 0: NVM is programmed with correct values, except if INTFLAG.SEESOVF was thrown.
    • otherwise; new data is in the page buffer, but is not yet programmed in the NVM.