Problems with I2C comms with external EEPROM

atharvai

Senior Member
Hi I'm using a PICAXE-18X with a external EEPROM (64K it is similar to other EEPROMs supplied by techsupplies. even the pin configs are the same) anyways... I'm recording data (just 1 and 0 for testing purposes) from input 2 and sending it on a I2C protocol every second. the code for writing the data to EEPROM is as follows:


'pin2 = input
'pin0 = record
'pin7 = serial send data to PC
'pin6 = read from mem button
'output 0 = record for tristate (write-protect)
'serout for LCD and PC
'b3 = data to send to PC
record:
low 0
for b0 = 0 to 250 step 1
if pin0 =1 then
let b1 = pin2
i2cslave %00000000, i2cslow8, i2cbyte
serout 7, N2400, (254,128,#b0,"= ", #b1)
serout 7, N2400, (254,192,"Recording... ")
writei2c b0, (b1)
pause 990
elseif pin0 = 0 then
high 0
goto main
endif
next b0
'end of record

and my code for reading from EEPROM and send to PC is as follows: (the PIC communicates with the PC fine even all the numbers are fine but the data read from the ROM is always 0)

mem_pc:
if pin7 = 1 then
serout 7, N2400, (254,192, "Press send again")
if pin7 = 1 then
serout 7, N2400, (254,128, "Sending Data")
serout 7, N2400, (254,192, "Do NOT Disconnect")
for b0 = 0 to 249 step 1
''
i2cslave %00000000, i2cslow8, i2cbyte
readi2c b0,(b3)
sertxd (#b0, " ", #b3,13,10)
next b0
Endif
elseif pin7=0 then
goto mem_pc
endif
'end of mem_pc
(the lines may have wrapped, there are no syntax errors present)

one more thing u might want to know is that the address for the EEPROM is 000

thanks

here's the link to a txt file which was captured from Hyper terminal
http://lemonus.googlepages.com/PICtest4.txt

thanks

Edited by - atharvai on 02/04/2007 21:21:10

Edited by - atharvai on 02/04/2007 21:23:30
 

leftyretro

New Member
Well I'm just starting to get into I2C devices so I'm probaly not the one to answer your question correctly, however are you sure your EEPROM device address is 0?

As I've read each manufacture uses it's own built in 'hard wired' address bits and usually allows the user to append a few address bits to it, but all zeros for an address sounds rather strange. Can you give us the manufacture's part number for the EEPROM?
 

BeanieBots

Moderator
I agree with retrolefty. An address of zero is most unusual!
Anyway, assuming you have some brand new device that some semiconductor manufacturer has sent you for beta testing and the address of the prototype really is zero (I'm sure they'll give it a type specific address when it's properly released), then the only thing that could make the data all zeros would be a lack of pull up resistors on the I2C bus.
Hopefully you have a datasheet for it.
Double check just to make sure that it does use a device specific address such as the one used by all other memory devices.
Also double check that if it has hardware pins for setting a chip address that these are set to zero and not left floating.
Double check that it really is an I2C device and not something else like SPI.
 

jplinteau

New Member
i2cslave %00000000, i2cslow8, i2cbyte
is incorrect

You need i2cslave %1010AAA0, i2cfast8, i2cword

AAA is the hard wired address of the chip.
i2cfast8 can normally be used, and is faster.
i2cword is needed, along with a word variable for writei2c and readi2c unless you address only first 255 bytes of the EEPROM.

J-P
 

atharvai

Senior Member
the part i'm using is M24C64 "64K serial I2C Bus EEPROM" bought from Rapid online.
I have the pull up resistors on the bus.
however on reading the datasheet again i noticed under 'Memory Addressing' section it says "To address a memory array, the 4-bit Device Type Identifiyer is 1010b" so does that mean in the program i have to write i2cslave %10100000, i2cfast8,i2cbyte.
(i'm want to use i2c byte as i intend on storing a simple 8-bit number)

1 more question, the data sheet states that the EEPROM has auto address increament, dows that mean i don't need a for..next loop and i can just loop the label using goto and put a if condition for exiting the loop?

link tot he datasheet: http://www.rapidonline.com/netalogue/specs/73-3634.pdf

Edited by - atharvai on 03/04/2007 10:49:49

Edited by - atharvai on 03/04/2007 10:50:32
 

BrendanP

Senior Member
Heres how I do it, this is a line Ive used, this works fine.


i2cslave %10100000, i2cfast,i2cword


writei2c 128, ( "TO SET UP THE UNIT SIMPLY FOLLOW THE ONSCREEN PROMPTS")


 

Edited by - BrendanP on 03/04/2007 10:50:52
 

atharvai

Senior Member
thanks for all your replies...
i'll ammend my program and test it as sson as i have some free time...

 

jplinteau

New Member
<i>1 more question, the data sheet states that the EEPROM has auto address increament, dows that mean i don't need a for..next loop and i can just loop the label using goto and put a if condition for exiting the loop? </i>

The datasheet also says about that;

<i>The Page Write mode allows up to 32 bytes to be written in a single Write cycle, provided that they are all located in the same &#8217;row&#8217; in the memory: that is, the most significant memory address bits (b12-b5 for M24C64, and b11-b5 for M24C32) are the same </i>

Be carefull with EEPROM, You should never cross pages while writing more than 1 byte of data, and not all EEPROM support buffering 32 bytes.

J-P
 

Technical

Technical Support
Staff member
The i2cbyte and i2cword describe the address method, not the data you are writing (which is always a byte). Your EEPROM type uses a word address - look at the datasheet diagrams and you will see two address bytes (ie the address is a word).

If you have all the Ex pins wired to ground you must use

i2cslave %10100000, i2cfast,i2cword
writei2c 0,(1)
etc

Incrementing addresses sinmply means you can write up to 32 bytes at a time e.g.
writei2c 0,(1,2,3,4)

However those 32 bytes can only start at multiples of 32 (address 0,32,64 etc). If you start at address 30 you can only write 2 bytes because of the 32 byte page limitation
e.g. writei2c 30,(1,2)
 
Top