I have used the following code for accessing eeprom :
void EEPROM_write(unsigned int uiAddress,unsigned char ucData)
{
while(EECR & (1<<EEWE))
{
//do nothing
}
while(SPMCR & (1<<SPMEN));
EEAR = uiAddress;
EEDR = ucData;
EECR |= (1<<EEMWE);
EECR |= (1<<EEWE);
}
char EEPROM_read(unsigned int uiAddress)
{
while(EECR & (1<<EEWE))
{
//do nothing
}
EEAR = uiAddress;
EECR |=(1<<EERE);
return EEDR;
}
void EEPROM_write_str(unsigned int uiAddress,unsigned char* string,unsigned int size)
{
int i;
for(i=0;i<size;i++)
{
EEPROM_write(uiAddress+i,string[i]);
}
}
void EEPROM_read_str(unsigned int uiAddress,unsigned char* string,unsigned int size)
{
int i;
for(i=0;i<size;i++)
{
string[i] = EEPROM_read(uiAddress+i);
}
}
char str[]="hello ";
char str2[20];
int main()
{
usart_init(12);
//EEPROM_write_str(0,str,6);
EEPROM_read_str(0,str2,6);
usart_puts(str2,6);
}
In the above code, I first commented the EEPROM_read_str and usart_puts,...flashed it then commented the EEPROM_write_str function and removed comments from the other two and flashed again.despite this, the data does not get stored and the output shown in the terminal is yyyyy (hex- FF). What is the problem here? (Here USART_puts transmits the string taking the second argument as number of characters)