PDA

View Full Version : I2CWRITE on a 24LC512



oslinux
- 21st March 2007, 17:48
Hi all,

i've some problems writing with I2CWRITE to this EEPROM (24LC512), it's wired to the PIC and pulled up via two 4.7k res.

The pic sometime write, sometime not, this is the code:

'Dichiaro le variabili
W0 VAR WORD 'Memorizzazione I2C
SCL VAR PORTC.3 'Pin per la memoria I2C Clock
SDA VAR PORTC.4 'Pin per la memoria I2C Data
I VAR WORD 'Generica
Control VAR BYTE 'Costante byte di controllo EEPROM

Control = $A0 'Imposto il byte di controllo

OPTION_REG = %11101111

'Imposto la frequenza di oscillazione a 10 Mhz
DEFINE OSC 10

'Imposto le porte della PIC
TRISA = %11111111 'PortA Tutti input
TRISD = %11111111 'PortD Tutti input
TRISB = %00000001 'PortB Tutti output a parte 0
PORTB = %00000000 'PortB Tutti low
TRISC = %00000000 'PortC Tutti output
PORTC = %00000000 'PortC Tutti low

'Inizializzo l'EEPROM
EEPROMInit:
W0 = $0
for I = 0 to $18
I2cwrite SDA,SCL,CONTROL,I,[W0]
pause 10
next

in the initial state where all the addresses is FFFF, after i use this code i can see this state in the EEPROM:

0000: 1100 00FF 0000 0000 | ........
0008: 0000 FF11 0000 FF11 | ........
0010: FFFF FFFF FFFF FFFF | ........
0018: FFFF FFFF FFFF FFFF | ........
0020: FFFF FFFF FFFF FFFF | ........
0028: FFFF FFFF FFFF FFFF | ........
0030: FFFF FFFF FFFF FFFF | ........

Can you help me solving this problem?

Thank you,

Luca

EDIT:
I'm using a PIC16F877A

sougata
- 22nd March 2007, 05:49
Hi,

The EEPROM you mentioned has address inputs on pins 1 and 2. Hope you have tried them to ground and not floating.
BTW this EEPROM supports page write mode. That is you can dump 128 bytes of data to the EEPROM and wait 10mS rather than waiting 10mS for every byte.

GioppY
- 22nd March 2007, 07:48
Perhaps you forget "DEFINE I2C_SLOW 1"
Ciao

Dave
- 22nd March 2007, 11:56
oslinux, You don't need the "DEFINE I2C_SLOW 1" statement as the normal speed of this EEPROM is 400Khz.

Dave Purola,
N8NTA

oslinux
- 22nd March 2007, 12:39
No way, it's always writing the 90% (or less) of what it should...

Dave
- 22nd March 2007, 17:21
oslinux, Try replacing the 4.7k pullups with 2.2k. Also, what are you doing with A0,A1, and A2 hardware address pins?

Dave Purola,
N8NTA

oslinux
- 22nd March 2007, 17:24
A0, A1, A2 and WP are grounded, same problem with the 2.2K resistors, only some address are writed.

skimask
- 22nd March 2007, 17:42
A0, A1, A2 and WP are grounded, same problem with the 2.2K resistors, only some address are writed.

Can you get rid of the 24LC512 and try a 24LC256 instead, or at least a smaller eeprom chip?

Not that it would make a difference...but it might...ya never know.
Only reason I mention it is because lots of people have used (are using) the '256, don't think I've heard of anybody using a '512 yet. They are a bit on the new-ish side (2-3 years old I'd guess, maybe...maybe not).

Also, try writing the whole eeprom, start to finish, try all $00's, try all $ff's, try a few things in between. There will probably be some sort of failure pattern in the eeprom readback itself that we might be able to see from a dump from the chip that'll narrow down the problem.

oslinux
- 22nd March 2007, 18:09
Tried with the 256, and it does the same, i mean it does not write everything, anyway i have to use a 512, and when i will get my sample from microchip i will test the 1025, that's because i need more than 256k :S

Note that the 64 do the same thing...

Now i've put the whole thing in PROTEUS ISIS and i'v having the same problem, but i can see the log of the eeprom:




212.727201m [RX_CMD ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0006 RD/WR=Write.
223.593601m [RX_CMD ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0007 RD/WR=Write.
234.460001m [RX_CMD ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0008 RD/WR=Write.
245.326801m [RX_CMD ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0009 RD/WR=Write.
256.192801m [RX_CMD ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x000A RD/WR=Write.


Until Here it's all good, but...


256.708801m [RX_CMD ]: Command received: 0xEE (0b11101110). Device=7, Block=0x00, Address=0x0009 RD/WR=Write.
256.708801m [RX_CMD ]: Unknown command value (0xEE) received - command is ignored.

266.934401m [RX_CMD ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0009 RD/WR=Write.
267.134001m [RX_CMD ]: Command received: 0x0A (0b00001010). Device=5, Block=0x00, Address=0x0026 RD/WR=Write.
267.134001m [RX_CMD ]: Unknown command value (0x0A) received - command is ignored.

277.362001m [RX_CMD ]: Command received: 0xEE (0b11101110). Device=7, Block=0x00, Address=0x0026 RD/WR=Write.
277.362001m [RX_CMD ]: Unknown command value (0xEE) received - command is ignored.


Here it comes, it can't recognize the commands because for example, instead of receive this control byte:
0b10100000

it receive this:
0b00001010
or this:
0b11101110

it's like there's something missing, the eeprom don't receive the whole bytes, maybe the 10MHz OSC is not good?

Thx...

Luca

Dave
- 22nd March 2007, 18:24
oslinux , I have used the 24lc512, 24lc515, 24lc1025 in pairs, to date with out any problem. One thing I did find is that if you are running interrupts during the read or write process I would sometimes have incorrect data ether read or written to the EEPROM. I disable all interrupts during the write process and I haven't had any problems since....

Dave Purola,
N8NTA

oslinux
- 22nd March 2007, 18:28
:( no i'm not using interrupts, but aniway i've placed a DISABLE before the write...

GioppY
- 23rd March 2007, 06:59
Try to split the word in 2 bytes;

i2cwrite Sda,Scl,Ctrw,Addr,[TmpW.highbyte]
pause 10
Addr = Addr + 1
i2cwrite Sda,Scl,Ctrw,Addr,[TmpW.lowbyte]
pause 10
Addr = Addr + 1

Ciao

Jerson
- 23rd March 2007, 09:02
Hoping all is well with the hardware, you need to break the addr part into 2 bytes.

I2cwrite SDA,SCL,CONTROL,I.HighByte, I.LowByte, [W0]

I use this in my design and it works correctly with a 24c512

Jerson

oslinux
- 23rd March 2007, 14:57
Solved Solved Solved Solved
:D

i tried splitting the address in two with no success, but

i changed the resistors from 0,5W to 0,125W, from 2.2K to 4.7K and now it's working well!

Thank you all for your support!

Luca

mister_e
- 23rd March 2007, 14:58
it make no real sense but if it's working...

How many years/decade/century your Proto-Board (breadboard) have?

oslinux
- 23rd March 2007, 15:39
it's a breadboard from 4 years ago if i remember well, but it has been used for a lot of projects, and not only with wires of the right width!

I'll use my new proto-board in a better way, I PROMISE :D :D

mister_e
- 23rd March 2007, 16:12
Yeah i see... We all tried to fit over-rated Awg wires + few TO-3 working on +/- 80 VDc and/or 110/220 VAC on those gizmuth ;)

This remind me few plastic smells experiments...

skimask
- 23rd March 2007, 16:22
Or used a proto-board without the double-sided protective sticky tape on the back and decided it would be a good idea to lay the board down onto something electrically conductive?

Smoke, sparks, melted pieces/parts, popped circuit breakers, blown fuses, all sorts of fun!!!