Atmega EEPROM memory writing
All mega family microcontrollers have internal EEPROM memory. They can have from 512bytes to 4kBytes. EEPROM memory has its own physical space and is linearly organized. ITo access EEPROM memory in mega, there are three registers used: Address register, Data register, and Control register. Address register EEAR (EEPROM Address Register) comprises 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 an interrupt after the write cycle is finished. If the bit is set to ‘1’ and “I” bit in SREG, then EEPROM Ready interrupt is enabled. If the bit is set to ‘0’ – then the interrupt is disabled. EEMWE – EEPROM Master Write Enable. The EEMWE bit determines whether setting EEWE to one causes 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…