PDA

View Full Version : Writing / Reading EEPROM 24LC256 Problem



schmoddel
- 16th February 2004, 17:50
Hi Picers,
does anyone have experience in handling
an EEPROM 24LC256 via I2C.
I try writing / reading this device
with:

Example for write:

i2cwrite sda1, scl1, $a0, 10, [STR date\10] 'Writes at starting position 10 the array date(10)
pause 10

i2cwrite sda1, scl1, $a0, 50, [amp1_port] 'Writes one byte to position 50
pause 10

Example for read:

i2cread sda1, scl1, $a0, 10, [STR date\10] 'Reads at starting position 10 the array date(10)
pause 10

i2cread sda1, scl1, $a0, 50, [amp1_port] 'Reads one byte from posiotion 50
pause 10

Can somebody help?

Best Regards, Ralf

tcbcats
- 17th February 2004, 06:06
I think I have the same problem here.
18F452 @ 20 Mhz
44LC515 512K EEPROM
the read returns $10 on the first position I write to
Have tried all the speed defines but no luck.
My tests are at location 3200 dec.
Maybe someone will give us a clue....

My code is:
I2CWRITE , PortC.4. PortC.3, %10100001, WW, [$4E]
PAUSE 10
---------------------
where WW is 3200 decimal defined as a word var.

tcbcats

tcbcats
- 17th February 2004, 09:07
Forgot to set...
DEFINE I2C_SCLOUT 1

You need to do this if you have no pullup resistor on the external EEPROM clock line.

tcbcats

schmoddel
- 17th February 2004, 10:00
Hi there,
some important things:

1. The address must be a variable of type word

2. Using the PIC over 8MHz the DEFINE I2C_SLOW = 1 must be set

3. The command byte when reading from i2cbus is automaticaly incremented by "1"

My EEPROM won't run in the moment, but i will find the mistake....

Ralf

NavMicroSystems
- 27th February 2004, 19:55
As mentioned in another thread I'm in the middle of a migration from 16F87x to 18Fxx2 and changing the crystal from 12MHz to 20 MHz.

My experience is:

DEFINE I2C_SLOW 1
DEFINE I2C_SCLOUT 1

does not solve the problem
in addition a pull-up is required at least on the data line.

I have put pull-ups on both the clock and data line and now it works fine.