4.9.3.3.1.4 EECR – EEPROM Control Register
| Name: | EECR |
| Offset: | 0x01F |
| Reset: | 0x00 |
| Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
| NVMBSY | EEPAGE | EEPM[1:0] | EERIE | EEMWE | EEWE | EERE | |||
| Access | R | R/W | R/W | R/W | R/W | R/W | R/W | R/W | |
| Reset | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
Bit 7 – NVMBSY Non-volatile Memory Busy
Bit 6 – EEPAGE EEPROM Page Access (Multiple Bytes Access Mode)
1’
enables multiple bytes access mode. This means that several bytes can be programmed
simultaneously into the EEPROM. After the EEPAGE bit is written to
‘1’, the EEPAGE bit remains set until an EEPROM program
operation is completed. Alternatively, the bit is cleared when the temporary EEPROM
buffer is flushed in software (see EEPM bits description). Any write to EEPAGE while
EEWE is ‘1’ is ignored. For more details on how to load data into
the temporary EEPROM page and the usage of the EEPAGE bit, see Programming
Multiple Bytes in One Atomic Operation in the EEPROM Data Memory from
Related Links.Bits 5:4 – EEPM[1:0] EEPROM Programming Mode Bits
| EEPM1 | EEPM0 | Programming Time | Operation |
|---|---|---|---|
| 0 | 0 | TEE_ER_WR(1) | Erase and write in one operation (atomic operation) |
| 0 | 1 | TEE_ER(1) | Erase only |
| 1 | 0 | TEE_WR(1) | Write only |
| 1 | 1 | — | Flush temporary EEPROM page buffer |
Note: For more details on the timing values, see
Timing Characteristics from Related Links.
Bit 3 – EERIE EEPROM Ready Interrupt Enable
1’ enables the EEPROM ready interrupt if the I bit in SREG is set. Writing EERIE to ‘0’ disables the interrupt. The EEPROM ready interrupt generates a constant interrupt when EEWE is cleared.Bit 2 – EEMWE EEPROM Host Write Enable
1’ causes the EEPROM to be written. When EEMWE is set, setting EEWE within four clock cycles writes data to the EEPROM at the selected address. If EEMWE is ‘0’, setting EEWE has no effect. After EEMWE is written to ‘1’ by software, hardware clears the bit to ‘0’ after four clock cycles. See the description of the EEWE bit for an EEPROM write procedure.Bit 1 – EEWE EEPROM Write Enable
1’ to write the value into the EEPROM. The
EEMWE bit must be written to ‘1’ before a logical
‘1’ is written to EEWE, otherwise, no EEPROM write takes place.
The following procedure must be followed when writing the EEPROM (the order of steps
3 and 4 is not important):- Wait until EEWE becomes
‘
0’. - Wait until SELFPRGM in SPMCSR
becomes ‘
0’. - Write new EEPROM address to EEAR (optional).
- Write new EEPROM data to EEDR (optional).
- Write a logical
‘
1’ to the EEMWE bit while writing a ‘0’ to EEWE in EECR. - Within four clock cycles
after setting EEMWE, write a logical ‘
1’ to EEWE.
CAUTION: An interrupt
between step 5 and step 6 makes the write cycle fail because the EEPROM host
write enable times out. If an interrupt routine accessing the EEPROM interrupts
another EEPROM access, the EEAR or EEDR register is modified, causing the
interrupted EEPROM access to fail. It is recommended that the global interrupt
flag be cleared during all the steps to avoid these problems. When the write
access time has elapsed, the EEWE bit is cleared by hardware. The user software
can poll this bit and wait for a ‘
0’ before writing the next
byte. After EEWE is set, the CPU is stopped for two cycles before the next
instruction is executed.Bit 0 – EERE EEPROM Read Enable
1’ to trigger the EEPROM read. The EEPROM read access takes one instruction and the requested data is available immediately. When the EEPROM is read, the CPU is stopped for four cycles before the next instruction is executed. The user must poll the EEWE bit before starting the read operation. If a write operation is in progress, it is neither possible to read the EEPROM nor change the EEAR register.