haxan
New Member
HI,
earlier i had a function for reading/writing into internal EEPROM for PIC18F4480.
When i switched to PIC18F4520, the code is not working anymore.
From the datasheet of PIC18F4520 it says:
from which i wrote the following C function:
can anyone please guide what can i be doing wrong here?
earlier i had a function for reading/writing into internal EEPROM for PIC18F4480.
When i switched to PIC18F4520, the code is not working anymore.
From the datasheet of PIC18F4520 it says:
MOVLW DATA_EE_ADDR ;
MOVWF EEADR ; Data Memory Address to read
BCF EECON1, EEPGD ; Point to DATA memory
BCF EECON1, CFGS ; Access EEPROM
BSF EECON1, RD ; EEPROM Read
MOVF EEDATA, W ; W = EEDATA
from which i wrote the following C function:
unsigned char EEPROM_read(unsigned char eeprom_addr)
{
EEADR = eeprom_addr;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.RD = 1;
return EEDATA;
}
can anyone please guide what can i be doing wrong here?