title: Writing and Reading data to EEPROM sequentially
body: <p>I am working on my college project which needs to store data in EEPROM of AtMega32.
  I am able to write and read data at any particular location of memory. But when I try to write data sequentially form address 0 to 1023 I am getting wrong values.</p>
  
  <p>Here are the functions I have written.</p>
  
  <p>Function definition to read and write data</p>
  
  <pre><code>#include "eeprom.h"
  
  uint8_t EEPROMRead(uint16_t uiAddress)
  {
      /* Wait for completion of previous write */
      while(EECR &amp; (1&lt;&lt;EEWE));
      /* Set up address register */
      EEAR = uiAddress;
      /* Start eeprom read by writing EERE */
      EECR |= (1&lt;&lt;EERE);
      /* Return data from data register */
      return EEDR;
  }
  
  void EEPROMWrite(uint16_t uiAddress, uint8_t ucData)
  {
      /* Wait for completion of previous write */
      while(EECR &amp; (1&lt;&lt;EEWE));
      /* Set up address and data registers */
      EEAR = uiAddress;
      EEDR = ucData;
      /* Write logical one to EEMWE */
      EECR |= (1&lt;&lt;EEMWE);
      /* Start eeprom write by setting EEWE */
      EECR |= (1&lt;&lt;EEWE);
  }
  </code></pre>
  
  <p>Here is main function</p>
  
  <pre><code>static int epadr=0;
  epread=EEPROMRead(epadr);      //reading from address stored in epadr
  printf("%d",epread);           //printing values
  
  
  if(epadr&lt;=1023)
      {
          EEPROMWrite(epadr,high);    //writing at address stored in epadr
          epadr++;                   //increment address
      }
  }
  
  if(epadr&gt;1023)
  printf("Memory Full\n");
  </code></pre>
  
  <p>I want to store data from location 0 to 1023. Please tell what is wrong with this code.</p>