EEPROM ISSUE

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just started using internal EEPROM. I am trying to write "8051" on 0,1,2,3 location of EEPROM and then read it (turn off and then). so first I write on it by

#include <avr/io.h>
#include <avr/eeprom.h>
#include "LCD16x2_4bit.h"
#define  F_CPU 1000000UL
#include <util/delay.h>

int main(void)
{
	uint8_t x;
	LCD_Init();
	LCD_Clear();
	LCD_String("Writing;");
  eeprom_write_byte((uint8_t*)0,'8');
   eeprom_write_byte((uint8_t*)1,'0');
    eeprom_write_byte((uint8_t*)2,'5');
	 eeprom_write_byte((uint8_t*)3,'1');
	 LCD_String_xy(2,0,"writing complete");
	 _delay_ms(500);
	 LCD_Clear();
	 LCD_String("Reading:");
	 x=eeprom_read_byte((uint8_t*)0);
	 LCD_Char(x);
	 x=eeprom_read_byte((uint8_t*)1);
	 LCD_Char(x);
	 x=eeprom_read_byte((uint8_t*)2);
	 LCD_Char(x);
	 x=eeprom_read_byte((uint8_t*)3);
	 LCD_Char(x);

    while (1)
    {
    }
}

it works fine and I get this

 

I wrote another program to read bytes again which is 

#include <avr/io.h>
#include <avr/eeprom.h>
#include "LCD16x2_4bit.h"
#define  F_CPU 1000000UL
#include <util/delay.h>

int main(void)
{
	uint8_t x;
	LCD_Init();
	_delay_ms(500);
	LCD_Clear();
	LCD_String("Reading:");
	x=eeprom_read_byte((uint8_t*)0);
	LCD_Char(x);
	x=eeprom_read_byte((uint8_t*)1);
	LCD_Char(x);
	x=eeprom_read_byte((uint8_t*)2);
	LCD_Char(x);
	x=eeprom_read_byte((uint8_t*)3);
	LCD_Char(x);

	while (1)
	{
	}
}

and this does not work and I get this

 

I don't know why is this happening.

This topic has a solution.
Last Edited: Thu. Jul 5, 2018 - 08:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

EESAVE !!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Means??

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He means the EESAVE fuse must be set to prevent EEPROM from being erased when you burn the second program. 

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So i will make EESAVE 0
Thanks