Discussion in "Project Doubts" started by    kathirdot    Mar 18, 2013.
Mon Mar 18 2013, 05:34 pm
#1
In my project i want to write some values to eeprom.Problem is when reading the eeprom the value comes 255 or 0xFF.The code is,

#define F_CPU 16000000UL
#include<avr/io.h>
#include<util/delay.h>
#include<avr/eeprom.h>
#include<util/interrupt.h>
void EEPROM_write(unsigned int Address, unsigned int Data);
unsigned int EEPROM_read(unsigned int Address);
unsigned int c=0;

int main(void)
{

EEPROM_write(0x01,0x07);

_delay_ms(50);

c=EEPROM_read(0x01);

_delay_ms(50);

while(1)
{
To_7seg(c);
}
}


void EEPROM_write(unsigned int Address,unsigned int Data)
{

while(EECR & (1<<EEWE));

EEAR = Address;

EEDR = Data;

EECR |= (1<<EEMWE);

EECR |= (1<<EEWE);

}


unsigned int EEPROM_read(unsigned int Address)
{

while(EECR & (1<<EEWE));

EEAR = Address;

EECR |= (1<<EERE);

return(EEDR);


}

kindly give the solution for this problem....
Mon Mar 18 2013, 11:40 pm
#2
Which compiler are you using ?
Does it have any built in EEPROM functions ?
Tue Mar 19 2013, 10:57 am
#3
compare your writing procedure with following:


Tue Mar 19 2013, 12:49 pm
#4

i am able to read the data when eeprom write and eeprom read functions are executing.but if i am comment the write eeprom function after once write, not able to read the correct data.the value comes 255.kindly give me the solution for this problem.
Wed Mar 20 2013, 10:19 am
#5
Please check datasheet (page 21)for help. It has got sample code for read/write. If you are still not able to solve. Post back here
Attachment

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Dulcehet
Fri May 10 2024, 04:22 pm
RonaldNak
Thu May 09 2024, 07:45 pm
Jamescon
Thu May 09 2024, 12:52 pm
RobertSkats
Thu May 09 2024, 10:23 am
hvCar
Thu May 09 2024, 05:53 am
DJGlido
Wed May 08 2024, 09:28 pm
migCar
Wed May 08 2024, 04:48 pm
TimmyJup
Wed May 08 2024, 12:22 am