EEPROM Programming in ATMega32

EEPROM 

The ATmega32 contains Built-In 1024 bytes of data EEPROM memory. The EEPROM Memory is also known as main memory and used to hold the data permanently (i.e. until we erase or overwrite).The EEPROM memory is used to load or store data .It is organized as a separate data space, in which single bytes can be read and written. The EEPROM has an endurance of at least 100,000 write/erase cycles. The access between the EEPROM and the CPU is described in the following registers,

  • EEPROM Address Registers
  • EEPROM Data Register
  • EEPROM Control Register

 

EEPROM Address Register (EEAR):

          This register is used to hold the address of the location where we want to read or write.The  address of EEPROM ranges from 0×0000 to 0x03FF

 Bits 15:10:These bits are reserved bits in the ATmega32 and will always read as zero.

Bits 9:0 :The EEPROM Address Registers EEARH and EEARL – specify the EEPROM address in the 1024 bytes EEPROM space. The EEPROM data bytes are addressed linearly between 0 and 1023. The initial value of EEAR is undefined. A proper value must be written before the EEPROM may be accessed.

EEPROM Data Register(EEDR)

For the EEPROM write operation, the EEDR Register contains the data to be written to the EEPROM in the address given by the EEAR Register. For the EEPROM read operation, the EEDR contains the data read out from the EEPROM at the address given by EEAR.

The EEPROM Control Register – EECR

Bits 7:4 :These bits are reserved bits in the ATmega32 and will always read as zero.

EERIE:Writing EERIE to one enables the EEPROM Ready Interrupt if the I bit in SREG is set.Writing EERIE to zero disables the interrupt. The EEPROM Ready interrupt generates a constant interrupt when EEWE is cleared.

EEMWE: 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 is zero, setting EEWE will have no effect When EEMWE has been written to one by software, hardware clears the bit to zero after four clock cycles.

EEWE: The EEPROM Write Enable Signal to start the write operation this bit has to set to logical one. After making this bit logical one the write operation start (if EEMWE is also logical one) and wait till this bit becomes zero for write complete.

EERE: This read enable bit, to start the read operation this bit has to set to logical one. After making this bit logical one the read operation start and wait till this bit becomes zero for read complete.

 Procedure for Write:

  • Load the address in EEAR
  • Load  data  to be stored to EEDR
  • To enable the EEPROM write make  EEMWE and EEWE bit in EECR to Logical One
  • Wait till EEWE in EECR becomes Zero.

Program

     Write a program to store data C in the location 0×0000.

Code:

    

Block Diagram:

 

Downloads:

Click here to download pdf

 

This entry was posted in EEPROM and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>