Hello,
For a project i need access to the internal eeprom of a PIC18F4685.
I use the functions below, but it didn't work. Can someone tell what i'm doing wrong? I'm using the latest version of MPlab X and XC8.
Eeprom memory is not code protected and no interrupts are used..
//EEPROM routines
char rd (char e_addr)
{
EEADR = e_addr; //Data Memory Address to read
EECON1bits.EEPGD = 0 ; //Point to DATA memory
EECON1bits.RD = 1; //EEPROM Read
return EEDATA;
}
void wr (char e_addr, char e_value)
{
EEADR = e_addr; //Data Memory Address to write
EEDATA = e_value; //Data Memory Value to write
EECON1bits.EEPGD = 0 ; //Point to DATA memory
EECON1bits.WREN = 1; //Enable writes
EECON2 = 0x55; //Write 55h
EECON2 = 0xAA; //Write AAh
EECON1bits.WR = 1; //Set WR bit to begin write
while (EECON1bits.WR)continue;
EECON1bits.WREN == 0;
}
For a project i need access to the internal eeprom of a PIC18F4685.
I use the functions below, but it didn't work. Can someone tell what i'm doing wrong? I'm using the latest version of MPlab X and XC8.
Eeprom memory is not code protected and no interrupts are used..
//EEPROM routines
char rd (char e_addr)
{
EEADR = e_addr; //Data Memory Address to read
EECON1bits.EEPGD = 0 ; //Point to DATA memory
EECON1bits.RD = 1; //EEPROM Read
return EEDATA;
}
void wr (char e_addr, char e_value)
{
EEADR = e_addr; //Data Memory Address to write
EEDATA = e_value; //Data Memory Value to write
EECON1bits.EEPGD = 0 ; //Point to DATA memory
EECON1bits.WREN = 1; //Enable writes
EECON2 = 0x55; //Write 55h
EECON2 = 0xAA; //Write AAh
EECON1bits.WR = 1; //Set WR bit to begin write
while (EECON1bits.WR)continue;
EECON1bits.WREN == 0;
}
Last edited: