-
24LC256 Serial EEPROM
The 24lc256 has a page size of 64 bytes i am trying to input the values 0 to 63 into the eeprom and then pull them out again into a different array.
Cannot seem to get it right cant read the full 64 bytes the last byte reads 0 or 255 What am i doing wrong here?
Cheers.
ADCON1.3 = 0
ADCON1.2 = 1
ADCON1.1 = 1
ADCON1.0 = 0
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
Define LCD_DREG PORTD
Define LCD_DBIT 0
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1
Define LCD_RWREG PORTE
Define LCD_RWBIT 2
COUNTERx var byte[63]
COUNTERy var byte[63]
ADDR VAR WORD
X VAR byte
Y VAR byte
LET ADDR = $0000
for Y = 0 to 63
COUNTERX[Y] = Y
NEXT Y
PAUSE 1000
i2cwrite PORTD.4,PORTD.5,$A000,ADDR,[STR COUNTERX\64]
PAUSE 1000
PAUSE 50
Lcdout $FE,1
LCDOUT "TEST"
LCDOUT $FE,$C2,"TEST"
PAUSE 1000
LET ADDR = $0000
I2CREAD PORTD.4,PORTD.5,$A000,ADDR,[STR COUNTERY\64]
PAUSE 2000
FOR X = 0 TO 63
LCDOUT $FE,1
LCDOUT #COUNTERY[X]
PAUSE 500
NEXT X
end
-
For a start you've only defined 63 byte Arrays... and then you try to read 64 bytes into it! Try...
COUNTERx var byte[64]
COUNTERy var byte[64]
Whilst arrays are numbered starting from ZERO, the definition has to contain the actual size... because...
COUNTERx var byte[0]
... is an illegal definition as you've defined ZERO elements for the array... so you need to define at least one element...
COUNTERx var byte[1]
...in order to access COUNTERx(0).
-
Hi Melanie
Thanks will try it.
-
Hi,
Also i found that i was sending a two byte control code which was displacing the array elements ($A000) it should have been $A0
Thanks all is working as expected.