PDA

View Full Version : 24LC256 Page problem



Josuetas
- 15th September 2006, 19:47
Hi!!!
I am having this problem: my memory writes and reads fine until it has to write in a change page byte (around 64 bytes). The thing here is that my "data packet" is 24 bytes and while writing through 64 bytes I get wrong bytes.

this is my code for writing:
**********************************************
**********************************************
Writemem:
lcdout "Writing"
I2Cwrite SDAmem,SCLmem,$A0,addr,[reciboH, reciboL.byte1, reciboL.Byte0]
pause 10
addr= addr+3
I2Cwrite SDAmem,SCLmem,$A0,addr,[Numeromarc[CabRx*10],Numeromarc[CabRx*10+1],Numeromarc[CabRx*10+2],Numeromarc[CabRx*10+3],Numeromarc[CabRx*10+4],Numeromarc[CabRx*10+5],Numeromarc[CabRx*10+6],Numeromarc[CabRx*10+7]_
,Numeromarc[CabRx*10+8],Numeromarc[CabRx*10+9]]
pause 10
addr= addr+10
I2Cwrite SDAmem,SCLmem,$A0,addr,[RTCDay, RTCMonth, RTCYear, Hourinicio[Cabrx], minsinicio[Cabrx], Secsinicio[Cabrx]]
pause 10
addr=addr+6
I2Cwrite SDAmem,SCLmem,$A0,addr,[hourscall[Cabrx],minscall[Cabrx],secscall[Cabrx]]
pause 10
addr=addr+3
I2Cwrite SDAmem,SCLmem,$A0,addr,[TotalActCab [Cabrx]]
pause 10
addr= addr+2

write regsmemHm, addr.byte1 'proxima dirección de mem a escribir
write regsmemLm, addr.byte0

'**************AUMENTAR NUMRECIBO
if reciboL = 65535 then
reciboH=reciboH+1
reciboL=0
else
reciboL=reciboL+1
endif

write reciboHm, reciboH
write reciboLlowm, reciboL.byte0
write reciboLHighm, reciboL.byte1
return
**********************************************
**********************************************

What should I do? do i have to write one byte at the time?

Thanks in advance!!

DAVIDCAS

JosueCas
- 15th September 2006, 21:35
Ok so i read back everything!, the datasheet of the EEPROM memory clearly states that you can't write over a page cross(every 64 bytes).

My ideas:

Solution number one: you can write one byte at the time, but this gives a 240 ms delay just for writing which is bad!!! bad!!!.

Solution number two: find the "less common denominator" (not sure off the name as i speak spanish and i hadnt used this concept since i was like two:D)
So if my packet is 24 bytes and the page is 64 bytes i can write 8 bytes packages being sure that i will never write across page boundaries. So now my delay will be of 30 ms instead of 240 ms.

This is not the perfect solution, maybe the next generation of the I2C command can control this automatically.

Thanks for any opinion,


DAVIDCAS

Melanie
- 16th September 2006, 09:15
How tight are you for space in your EEPROM? If it's tight, oversize your EEPROM...

Allocate only two data packets per page... the first starts at Byte 0 and goes to byte 23, the second starts at byte 32 and goes to byte 55. This technically wastes 8 bytes at the end of each packet (wasting 16 bytes per page) but it does give two advantages...

1. You have a 10mS total write time.

2. It gives expansion for 'future creep' where at some point in time your data packet grows beyond 24 bytes, you can then incorporate such expansion without a major rewrite of your code.