those are the two functions of read and write
////////////EEPROM.c//////////////
void IEEPROM_Write(u16 A_u16Adress, u8 A_u8Data)
{
/* Wait for completion of previous write */
while(GET_BIT(EECR,EECR_EEWE)==1);
/* Set up address and data registers */
EEAR = A_u16Adress;
EEDR = A_u8Data;
/* Write logical one to EEMWE */
SET_BIT(EECR,EECR_EEMWE);
/* Start eeprom write by setting EEWE */
SET_BIT(EECR,EECR_EEWE);
}
u8 IEEPROM_Read(u16 A_u16Adress)
{
/* Wait for completion of previous write */
while(GET_BIT(EECR,EECR_EEWE)==1);
/* Set up address and data registers */
EEAR = A_u16Adress;
/* Start eeprom read by setting EERE */
SET_BIT(EECR,EECR_EERE);
return EEDR;
}
////////////EEPROM.h//////////////
#define EEARH (*(volatile u8 *)0x3F)
#define EEARL (*(volatile u8 *)0x3E)
#define EEAR (*(volatile u16 *)0x3E)
#define EECR (*(volatile u8 *)0x3C)
#define EECR_EERE 0
#define EECR_EEWE 1
#define EECR_EEMWE 2
#define EECR_EERIE 3
#define EEDR (*(volatile u8 *)0x3D)
void IEEPROM_Write(u16 A_u16Adress, u8 A_u8Data);
u8 IEEPROM_Read(u16 A_u16Adress);
I followed the instructions of the ATMEGA32 Datasheet but it the code doesn't work I write a number on a byte then I read it and display it on LCD , but it prints 255,