Writing sequential Data to EEPROM problems

noycesd

New Member
With some great help I have managed to get my clock data writing at regular intervals to the eeprom chip. However I seem to have a bug, the increments for the write address go up in tens (for ease of tracking / recovering the data), everything is fine up until address location 60 after which the next write address jumps to 2059. I have erased the eeprom and re-uploaded the programme, and occasionally it will run as expected but mostly jumps from 60 to 2059.

Any help (you've been great already) would be much appreciated.

Si.

Code:-

main:
high 0
pause 150
i2cslave %10100000, i2cfast, i2cword 'initialise eeprom
readi2c 0,(b0,b1) 'read loc 0
pause 50
w4=w0+10 'increment address by 10
writei2c 0,(b8,b9) 'write new location w4 to location 0 on eeprom
low 0
pause 100
goto clock
end

clock:


i2cslave %11010000, i2cslow, i2cbyte 'inialise clock
readi2c 0,(b0,b1,b2,b3,b4,b5,b6) 'read clock
pause 100

i2cslave %10100000, i2cfast, i2cword 'initialise eeprom
writei2c w4,(b0,b1,b2,b3,b4,b5,b6) 'write clock data to eeprom at location w4
pause 10
sertxd (#w4," ",#b0,#b1,#b2,#b3,#b4,#b5,#b6,13,10)'output data to serial port to check
pause 50
 

westaust55

Moderator
Okay so we know you have a 24LC256 EEPROM.
These have a 64 byte paging structure.
I have mentioned this paging structure in your earlier thread.

So as I see it, the first 6 block writes are okay but then when you try to write out the next block, addresses 61, 62 . . . 70, when it gets to 64 it rolls over.

as a trial, can I suggest/ask that you try using an increment of 8 instead of 10 for a test. If that overcomes the immediate problem then we can look at how to allow you to handle 10 bytes of data as the enxt step (lets do it 1 step at a time).

so in place of:
w4=w0+10 'increment address by 10

try:
w4=w0+8 'increment address by 8

give that a try and see if the jump from 60 to 2059 problem still exists.
 

ValueAdd

Senior Member
I for one keep learning more from these queries by others and the responses.

There are many on this forum who can get a program working for us newbies.
A few have the ability to describe well the application and reasons.
 

ylp88

Senior Member
For reference, the actual quote from the datasheet is:

Microchip DS21203P said:
If a Page Write command attempts to write
across a physical page boundary, the
result is that the data wraps around to the
beginning of the current page (overwriting
data previously stored there), instead of
being written to the next page, as might be
expected. It is, therefore, necessary for the
application software to prevent page write
operations that would attempt to cross a
page boundary.
ylp88
 

westaust55

Moderator
profipsy,

great to hear that it working correctly.

With the 24LC256, as mentioned earlier, the page size is 64 bytes.

When you advance to 10 bytes of data in each the simplest solution will be to increment in steps of 16 instead of 8 bytes.
That does however waste 6 bytes (37%) of the memory. You will get 2048 record groups into a single EEPROM with that method.

Is that acceptable or are you looking to compact more?

10 bytes could be 6 record sets per 64-byte page or 2037 recordsets total per EEPROM but needs to watch the addressing to avoid problems at page boundaries. (only 6% memory wastage that way)
 

noycesd

New Member
I have managed to condense my data dowm to just 8 bytes, and figure as i dont need second accuracy could use the bytes from the seconds if i need to expand. Thanks again you support has been terrific.

Si.
 
Top