Atmega EEPROM memory writing

All atmega family microcontrollers have internal EEPROM memory. They can have from 512bytes to 4kBytes. EEPROM memory has its own memory space and is linearly organized. In order to access EEPROM mempry in atmega there are three registers used: Address register, Data register and Control register. Address register EEAR (EEPROM Address Register) is made of two 8 bit registers EEARH:EEARL. In this register the EEPROM cell address has to be loaded. Data register EEDR (EEPROM Data Register). When writing to EEPROM the data is loaded to this register. When getting data from EEPROM – you read data from this register. Control register EECR (EEPROM Control Register) is used to control access to EEPROM memory. EERIE – EEPROM Ready Interrupt Enable. This bit generates interrupt after write cycle is finished. If bit is set to ‘1’ and also I bit SREG, then EEPROM Ready interrupt is enabled. If bit is set to ‘0’ – then interrupt is disabled. EEMWE – EEPROM Master Write Enable. The EEMWE bit determines whether setting EEWE to one cause the EEPROM to be written. When EEMWE is set, setting EEWE within four clock cycles will write data to the EEPROM at the selected address If EEMWE…

Continue reading