Shop OBEX P1 Docs P2 Docs Learn Events
Help writing to eeprom — Parallax Forums

Help writing to eeprom

mynet43mynet43 Posts: 644
edited 2010-09-03 13:20 in Propeller 1
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

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-03 13:15
    It takes the EEPROM 5+ms to complete the write operation and WritePage doesn't wait. Your program is probably trying to read the EEPROM before it's completed the write operation and it will ignore the read operation request.

    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.
  • mynet43mynet43 Posts: 644
    edited 2010-09-03 13:20
    Thank you Mike!!!

    That was it. Worked perfectly, returned the correct values.

    Jim
Sign In or Register to comment.