Help writing to eeprom
mynet43
Posts: 644
I'm trying to write, then read, some data from the Prop eeprom.
My eeprom is an AT24C512, which has 65KB storage.
I'm attempting to write and read the data at the beginning of the second half of the eeprom, above the code space.
When I write the data, it seems to work OK. I don't get back an error code.
However, when I try to read it back, it returns error code 15.
Would someone please take a look at my code and help me understand what I'm doing wrong?
The screen output I get is: Calib EEPROM read error: 15 -- x0, tilt90: -1 -1
I've attached the test code I'm using.
Thank you for your help.
Jim
My eeprom is an AT24C512, which has 65KB storage.
I'm attempting to write and read the data at the beginning of the second half of the eeprom, above the code space.
When I write the data, it seems to work OK. I don't get back an error code.
However, when I try to read it back, it returns error code 15.
Would someone please take a look at my code and help me understand what I'm doing wrong?
The screen output I get is: Calib EEPROM read error: 15 -- x0, tilt90: -1 -1
I've attached the test code I'm using.
Thank you for your help.
Jim
Comments
The easiest solution is to put a 10ms delay after the call to WritePage like this:
WAITCNT(CLKFREQ/100 + CNT)
The comments in Basic_I2C_Driver show how to put in a variable delay that waits for the EEPROM to respond rather than waiting a fixed amount of time.
Remember that you're writing 128 bytes and not all EEPROMs have a page size that large. In your case, the AT24C512 does have a 128 byte page.
That was it. Worked perfectly, returned the correct values.
Jim