PDA

View Full Version : I2CREAD issues with 24FC512 EEPROM



circuitpro
- 11th March 2010, 01:11
I've discovered a problem when using a PIC18F67J60 and 24FC512 EEPROM.

I've had this project in the field for several months now, and am just recently getting problems when I try to read a byte from the EEPROM. The code looked like this:

I2CREAD SDA,SCL,RD,(BCONFIG+KEY),[VTYPE]
PAUSE 5

The EEPROM holds "1" in this location, but has recently started to return "0".

If I do the addition first, the problem goes away, and the EEPROM returns "1" reliably!

MEM=BCONFIG+KEY
I2CREAD SDA,SCL,RD,MEM,[VTYPE]
PAUSE 5

I have just switched from ver 2.50 to 2.60, and some of these units have been recompiled using the new compiler. I have no other explaination for why this might be happening. Has anyone else determined that the math had best be done prior to the actual read? (Changing the pause time has no effect by the way.)

Just curious.

Kamikaze47
- 11th March 2010, 15:52
I'm not sure why it has changed, but is there really a problem with calculating the address first? Sounds to me like you have solved the problem.

circuitpro
- 11th March 2010, 16:38
Not at all. It's just a curiosity, and a slight concern for the units already deployed. Lesson learned.

Luckyborg
- 11th March 2010, 18:00
I had a similar problem with the write command. DT said it had something to do with adding LONGs in 2.6. You can see his response here (http://www.picbasic.co.uk/forum/showthread.php?t=12527)

Maybe something similar happened with the I2CREAD command

David

Melanie
- 11th March 2010, 18:18
I try to avoid doing Math in any I2CREAD or I2CWRITE statement. Do it first and keep the statements as clean as possible. Always do what the book says. It says use a particular kind of variable, then use a particular kind of variable. It doesn't say Math is allowed, and doesn't show you examples with Math - so don't do it.

You DON'T need PAUSEs for READING - you can do that at top speed. You DO need them for writing - the EEPROM Datasheet will tell you how much is required.

circuitpro
- 11th March 2010, 18:52
Thanks Luckyborg. Think DT answered the question, and will keep an eye on patches to 2.60.