PIC18f4620 EEPROM issue

Status
Not open for further replies.

adnan012

Advanced Member level 1
Joined
Oct 6, 2006
Messages
468
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
4,923
hi,

I want to save data in PIC18F4620 EEPROM. I am using MPlabx and XC8 compiler.

I am using bulit in functions. PIC18F4620 has 1k EEPROM. Is there any issue in 10bit EEprom addressing?

eeprom_write(address, value);
value = eeprom_read (address)

I am unable to read back correct data.
 

We have no idea how this functions works. May be some delay needed to perform correct writing. For such cases I prefer to write my own functions according manual.
 
The functions are for writing 1 byte data. For writing 10 bit data you have to use

Code:
eeprom_write(address + 1, (unsigned char)(value >> 8)); //low byte 
value = eeprom_read (address + 1)
value <<= 8;

eeprom_write(address, (unsigned char)value); //low byte 
value |= eeprom_read (address)
 
According to a comment in eeprom_routines.h, the library version does wait for write completion. But I would inspect the generated code to be sure.

 
The functions are for writing 1 byte data. For writing 10 bit data you have to use
I'm not sure that's true, the question referred to 10-bit ADDRESSING not 10 bits of data. However, the 18F4620 does have two 8-bit address registers for EEPROM access, EEADR and EEADRH with the two MSB of the address going to EEADRH. I'm not sure if XC8 takes that into account although I would be suprised if it didn't. I do not have a copy at hand to look at the code it produces at the moment.

Brian.
 
Reactions: Okada

    Okada

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…