deepakgupta.rf
Member level 4
hello everyone
some time what i feel ,my atmega8535 do not read eeprom value.
it process all the work properly but sometime it not read values from eeprom.again when i do reset ,then it works proper and show numbers exactly.
for(k=0;k<=29;k++)
{
numb[k]= eeprom_read_byte(k);
delay_ms(200);
}
///// eeprom write////////////
/
void write_eeprom_byte(char address, char data)
{
// EEARH=0x00;
// EEARL = address ;
while(EECR & 0x02 == 1) ; // CHECK EEWE BIT
while( SPMCR & 0x01 == 1); // CHECK SPMEN BIT
// EEARH=0x00; // SET ADDRESS MSB BYTE
EEARL = address ; // SET LSB BYTE OF ADDRESS
EEDR = data ; // WRITE data to be written to EEPROM
EECR = 0x04 ; // SET EEMWE BIT
#asm
// nop;
// nop;
#endasm
EECR = 0x06; // SET EEMWE & EEWE BITS
while(EECR & 0x04 == 1); // CHECK EEMWE IS CLRED
// delay_ms(10); // general delay
return;
}
////// eeprom read/////////////////////////////
char eeprom_read_byte(char address)
{
char data=0;
while(EECR & 0x02 == 1) ; // check EEWE BIT IS CLRed
// EEARH=0x00; // SET MSB BYTE OF ADDRESS
EEARL = address ; // SET LSB BYTE OF ADDRESS
EECR = 0x01 ; // SET EERE BIT
#asm
// nop;
// nop;
#endasm
data = EEDR; // read data from the EEPROM
return(data); // RETURN EEPROM data value
}
so sir plz what is the basic problem
some time what i feel ,my atmega8535 do not read eeprom value.
it process all the work properly but sometime it not read values from eeprom.again when i do reset ,then it works proper and show numbers exactly.
for(k=0;k<=29;k++)
{
numb[k]= eeprom_read_byte(k);
delay_ms(200);
}
///// eeprom write////////////
/
void write_eeprom_byte(char address, char data)
{
// EEARH=0x00;
// EEARL = address ;
while(EECR & 0x02 == 1) ; // CHECK EEWE BIT
while( SPMCR & 0x01 == 1); // CHECK SPMEN BIT
// EEARH=0x00; // SET ADDRESS MSB BYTE
EEARL = address ; // SET LSB BYTE OF ADDRESS
EEDR = data ; // WRITE data to be written to EEPROM
EECR = 0x04 ; // SET EEMWE BIT
#asm
// nop;
// nop;
#endasm
EECR = 0x06; // SET EEMWE & EEWE BITS
while(EECR & 0x04 == 1); // CHECK EEMWE IS CLRED
// delay_ms(10); // general delay
return;
}
////// eeprom read/////////////////////////////
char eeprom_read_byte(char address)
{
char data=0;
while(EECR & 0x02 == 1) ; // check EEWE BIT IS CLRed
// EEARH=0x00; // SET MSB BYTE OF ADDRESS
EEARL = address ; // SET LSB BYTE OF ADDRESS
EECR = 0x01 ; // SET EERE BIT
#asm
// nop;
// nop;
#endasm
data = EEDR; // read data from the EEPROM
return(data); // RETURN EEPROM data value
}
so sir plz what is the basic problem