I'm new to eeproms and I just don't get it.
Trying a 24LC256 with 18X.
There's no problem in writing and reading on value at a time, but I just can't successfully write and read 2 variables at once.
I would expect the test code below to look like this when reading the eeprom. (Or something like this).
0,0,10
1,1,11
2,2,12
3,3,13
4,4,14
5,5,15
6,6,16
7,7,17
8,8,18
9,9,19
10,10,20
Instead it reads back like this.
(Using the Program Editor f9 function)
0,1,2,
1,2,3,
2,3,4,
3,4,5,
4,5,6,
5,6,7,
6,7,8,
7,8,9,
8,9,10,
9,10,11,
10,11,12,
'TEST CODE
i2cslave %10100000,i2cslow,i2cword
high 0 'write protect EEPROM
b0=0:b1=10 'initial values
main:
for b11=0 to 50
if pin2 = 1 then PLAYBACK
low 0 'write enable eeprom
b0=b0+1:b1=b1+1 'increment b0 & b1
writei2c w6,(b0,b1) 'write the values
pause 10 'wait EEPROM write time
w6=w6+1 'increment eeprom location
next
finished:
if pin2 = 1 then PLAYBACK
pause 100
goto finished
PLAYBACK:
high 0
pause 1000
for w6=0 to 10
readi2c w6,(b0,b1) 'read b0 & b1 from eeprom
sertxd(#w6,44,#b0,44,#b1,13,10) 'send b0 & b1 to terminal
next
end
Trying a 24LC256 with 18X.
There's no problem in writing and reading on value at a time, but I just can't successfully write and read 2 variables at once.
I would expect the test code below to look like this when reading the eeprom. (Or something like this).
0,0,10
1,1,11
2,2,12
3,3,13
4,4,14
5,5,15
6,6,16
7,7,17
8,8,18
9,9,19
10,10,20
Instead it reads back like this.
(Using the Program Editor f9 function)
0,1,2,
1,2,3,
2,3,4,
3,4,5,
4,5,6,
5,6,7,
6,7,8,
7,8,9,
8,9,10,
9,10,11,
10,11,12,
'TEST CODE
i2cslave %10100000,i2cslow,i2cword
high 0 'write protect EEPROM
b0=0:b1=10 'initial values
main:
for b11=0 to 50
if pin2 = 1 then PLAYBACK
low 0 'write enable eeprom
b0=b0+1:b1=b1+1 'increment b0 & b1
writei2c w6,(b0,b1) 'write the values
pause 10 'wait EEPROM write time
w6=w6+1 'increment eeprom location
next
finished:
if pin2 = 1 then PLAYBACK
pause 100
goto finished
PLAYBACK:
high 0
pause 1000
for w6=0 to 10
readi2c w6,(b0,b1) 'read b0 & b1 from eeprom
sertxd(#w6,44,#b0,44,#b1,13,10) 'send b0 & b1 to terminal
next
end
Last edited by a moderator: