• PicŪ Basic


  • Retrieved data does not match entered data

    Storing data in EEPROM (24LCxx) is not very complicated. But it happens that the retrieved data may not match what was stored. After a certain amount of stored data, it seems that some data is corrupted.

    Here is the explanation given by Les on this:

    The compiler is not at fault, but your understanding of eeprom access is not complete. Eeproms are not as random access as people think, they work with pages. Some eeproms have a page of 8, 16, 32 or 64 bytes. The 24LC128, and 24LC256 have page boundaries of 64 bytes.

    If you examine the datasheet for the eeprom, you will see two forms of writing, PAGE access and RANDOM write. RANDOM writing must be within a 64 byte boundary, and cannot cross it without first sending a stop command and waiting for the memory to be allocated into the eeprom's matrix.

    So the boundaries are 0 to 63, 64 to 127, 128 to 191 and so on.

    Your code writes in multiples of 6 bytes without a STOP command being sent to the I2C bus, so when the count reaches 64, the eeprom automatically attempts to write a page, and ignores all other commands on the bus until it's finished, but your code is still trying to write another 4 bytes .i.e. 60 to 63.

    When performing RANDOM access to an eeprom, it must be on a single byte transfer, any more may violate the protocol.

    Reading from an eeprom is truly random access however.

    Try altering your code so that the step size is 8 in the for next loop, and write and read 8 bytes at a time. This will cure it.

    contributed by Olivier.
  • Recent Activity

    amod-29593

    Pulse counter using COUNTER command

    Thread Starter: amod

    How I can use counter command for counting pulses on portd.3 of 16f877A.Iam making a 8 digit object counter.

    amod Yesterday, 19:27 Go to last post
    teo-16018

    Assembler to Proton

    Thread Starter: teo

    Hello everybody, How can I translate from Assembler into Proton? --------------------------------------------------------------------------...

    teo Yesterday, 23:30 Go to last post
    Tim-107

    CWrite Issues on 16F

    Thread Starter: mjturner

    I want to commit some values to EEPROM, but it seems they no longer include the separate EEPROM area anymore. So I'm having to use the code flash...

    Tim Yesterday, 22:47 Go to last post
    teo-16018

    johngb has just uploaded Proton Studio Ver 1.0.1.6!

    Thread Starter: johngb

    johngb has just uploaded Proton Studio Ver 1.0.1.6! Updated Studio with the following. Fixed - when opening multiple files on start-up the order...

    teo Today, 05:54 Go to last post