PDA

View Full Version : Using 24LC65 eeprom



Wilson
- 19th September 2007, 10:15
I am trying to read and write to a 24LC65 eeprom.
I have checked all the hardware and its fine.
Something in my routine must be wrong.
The first 12 memory locations do not contain what I wrote to them
and only get 255 for the rest. Seems it is not writing properly.
I have read through the data sheet form Microchip
but I must have missed something.
To be honest, its a bit too technical for me.




scl var PORTC.3
sda var PORTC.4
addr var byte
y1 var byte
x1 var byte
start:
addr = 0
loop:

lcdout $FE, 1, "Eeprom Data ", #addr, " ", #y1

x1 = 255 - addr
i2cwrite sda, scl, $A0, addr, [x1]
pause 20
i2cread sda, scl, $A0, addr, [y1]
addr = addr +1
pause 500
if addr =100 then goto start

goto loop


Anybody want to leave me a clue as to where to go from here?

Wilson

BigWumpus
- 19th September 2007, 10:27
Yes!

Use the search-function in this forum.
A lot of guys has already solved your problem !

Inside the manual you find the behavoir of the I2CWRITE-command. It only sends 1 byte of adress if you give him a byte-sized variable. You must declare your adresscounter as a WORD !

sayzer
- 19th September 2007, 10:30
Try WRITE control byte as %10100000 or $A0

and

Try READ control byte as %10100001 or $A1.


----------------------------------

Wilson
- 19th September 2007, 11:06
Thanks.
Changed to addr variable from Byte to Word and its now okay.

Wilson