PDA

View Full Version : I2Cwritge - array



mpardinho
- 28th August 2007, 13:56
i write 4 time 100% no error, after 4 many caracters wrong
if i use "for" work 100%, but is slow
for i = 0 to 38
I2CWRITE MData, MClock, Controle, Posicao_Memoria, [Letra_2(i)]
Posicao_Memoria = Posicao_Memoria + 1
PAUSE 5
next i



------------------------------------------------------------------------
my code

I var byte
Controle var Byte
Posicao_Memoria VAR WORD
Letra_2 var byte[38]

Controle = $A0

WRITE 8, 0
WRITE 9, 0

for i = 0 to 38
Letra_2(i) = i
next i

loop:

' read adress
READ 8, Posicao_Memoria.HighByte
READ 9, Posicao_Memoria.LowByte


I2CWRITE MData, MClock, Controle, Posicao_Memoria, [STR Letra_2\38]
Posicao_Memoria = Posicao_Memoria + 38
PAUSE 5


' write adress
WRITE 8, Posicao_Memoria.HighByte
WRITE 9, Posicao_Memoria.LowByte

goto loop

Ruben Pena
- 28th August 2007, 23:43
Hi:
What EEPROM are you using.?. I think it is a 24LC32 or bigger,because the word address.
You must make the pause for each Write of 10 ms. Some memories do not like only 5.
Greetings...
Ruben de la Pena

GrandPa
- 29th August 2007, 01:09
Most EEPROM use a cache page of 8 bytes. You may encounter all kinds of problems if you try to write the same page in two subsequent write operations.Thus, I think it will be better to go with multiples of 8. Meaning you will use 40 instead of 38 in this statement: "Posicao_Memoria = Posicao_Memoria + 38". And the rest of the code should obviously go according to this. And yes, you probably need 10ms pause anyways.

Have a look at the datasheet to understand the difference between page write and byte write. You will find some other valuable informations too!

J-P

mpardinho
- 30th August 2007, 11:38
thanks brothers for help
i'll try multiples of 8