odd 24lc256 behaviour

oracacle

Senior Member
After making some changes to the memory alogorithum i found that storing data in a certian part of the eeprom caused altering data in blokes 60 below.

Code:
hi2cout address, (imagelow,imagehigh,apertlow,aperthigh,shutlow,shuthigh,whole_d,deci_d, overlap,strfocal)
is the comand that is used to store the data that is required, if address = 60 then issues arrise, it so far has been the only issue area of the new programme design. if address = 50, or 70 as far as i can tell anything else all is fine.

when a start address of 60 is used it overwrights the data stored in at least address 5 (it the address that stores if thing have been calibrated or not)

i wrote this little prorgamme for testing the wrting of the eeprom

Code:
[color=Blue]symbol eprom      [/color][color=DarkCyan]= [/color][color=Navy]%10101110[/color]
[color=Blue]symbol ret        [/color][color=DarkCyan]= [/color][color=Navy]13[/color]
[color=Blue]symbol lfeed      [/color][color=DarkCyan]= [/color][color=Navy]10[/color]
[color=Blue]symbol com        [/color][color=DarkCyan]= [/color][color=Navy]44
#no_table
#terminal 9600[/color]
[color=Black]init:
      [/color][color=Blue]high b.2
      hi2csetup i2cmaster[/color][color=Black], [/color][color=Blue]eprom[/color][color=Black], [/color][color=Blue]i2cslow[/color][color=Black], [/color][color=Blue]i2cword
      let [/color][color=Purple]b0 [/color][color=DarkCyan]= [/color][color=Navy]0
      [/color][color=Blue]let [/color][color=Purple]b1 [/color][color=DarkCyan]= [/color][color=Navy]100[/color]
[color=Black]main:
      [/color][color=Blue]high b.4
      for [/color][color=Purple]w1 [/color][color=DarkCyan]=  [/color][color=Navy]0 [/color][color=Blue]to [/color][color=Navy]100
      [/color][color=Blue]hi2cout [/color][color=Purple]w1[/color][color=Black],[/color][color=Blue]([/color][color=Purple]b0[/color][color=Black],[/color][color=Purple]b1[/color][color=Blue])
      pause [/color][color=Navy]10
            [/color][color=Blue]inc [/color][color=Purple]w1
            [/color][color=Blue]inc [/color][color=Purple]b0
            [/color][color=Blue]inc [/color][color=Purple]b1
      [/color][color=Blue]next [/color][color=Purple]w1
      [/color][color=Blue]low b.4

      let [/color][color=Purple]b0 [/color][color=DarkCyan]= [/color][color=Navy]0
      [/color][color=Blue]for [/color][color=Purple]w1 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]to [/color][color=Navy]100
      [/color][color=Blue]hi2cin [/color][color=Purple]w1[/color][color=Black],[/color][color=Blue]([/color][color=Purple]b1[/color][color=Blue])
      sertxd ([/color][color=Black]#[/color][color=Purple]w1[/color][color=Black],[/color][color=Navy]32[/color][color=Black],#[/color][color=Purple]b1[/color][color=Black],[/color][color=Blue]ret[/color][color=Black],[/color][color=Blue]lfeed)
      next [/color][color=Purple]w1     
      [/color][color=Blue]low b.2[/color]
the only thing that did suprise me at first was if i only wrote 1 variable (b0) it would write every other address, so address 2 would be 1, address 3 would be zero, address 4 would be 2.
after adding in the second variable to write (b1) every address was writen, and writen correctly from the data fed back to the terminal

address is variable w23 in the main programme, the others are byte variables. i2cslow was used as the FPU run at i2cslow
debug shows that address = 60 when error accours



Just looking back over some debuging data indicates that when address 60 is used it starts from adress 0
 

hippy

Technical Support
Staff member
when a start address of 60 is used it overwrights the data stored in at least address 5 (it the address that stores if thing have been calibrated or not)
This would appear to be an EEPROM 'page size' problem. You cannot write across page boundaries in a single I2C write command. Attempting to do so will alter data earlier in the page.

For example, with a 64 byte page size, the pages will be -

Page 0 : Locations 0 to 63
Page 1 : Locations 64 to 127
Page 2 : Locations 128 to 191
etc

If you start to write to location 60, you will update locations 60, 61, 62, 63 and then location 0, 1, 2, 3 etc.

For your test program; when reading or writing two bytes you need to increment the address by two. Again, you must take care not to perform writes which cross page boundaries.
 

oracacle

Senior Member
thanks guys, completely forgot about the page size thing. easiest way would be to wright each variable in its own hi2cout i supose. I take the reading of data is not restricted by such restraints?

as for the test programme writing to every other address, that was my fault, the programme used a for next loop based on the address (w1 in the test programme) which incremented the the address automatically, i had also included an inc w1 comand for some reason causing it to skip every other address essentially
Code:
for w1 = 0 to 100 step 2
 
Last edited by a moderator:

westaust55

Moderator
For sequential reads the internal address pointer is 15 bits and therefore does not roll over at page boundaries. Only when it reaches $7FFF does it roll over to $0000.
 
Top