27.5.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 *) SEEPROM_ADDR; 
    volatile uint16_t *SmartEEPROM16 = (uint16_t *) SEEPROM_ADDR; 
    volatile uint32_t *SmartEEPROM32 = (uint32_t *) SEEPROM_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];

WP command is triggered after any page buffer update.

INTFLAG.SEEWRC indicates when a AHB write to the SmartEEPROM has completed: NVM is programmed with correct values except if INTFLAG.SEESOVF was thrown.