Writing/Reading with EEPROMs

Hi guys!

i would like to write and read this kind of EEPROM http://ww1.microchip.com/downloads/en/DeviceDoc/21711G.pdf

the problem is that i don't really know how to.

My aim is to establish a serial connection with it via my picaxe (it's gonna be one of the "M" series), and of course, once i've done this, to read it and write on it.

does picaxe have some simple code to read/write them?

Another thing: in the pin description it says i have to connect a pin to a "serial clock". What is that? or what pin would it be on the picaxe?

They are I2C devices and you
They are I2C devices and you should connect them to the I2C pins on your picaxe. I suggest you read the picaxe docs on I2C and see if they can help you on the way. I have some I2C EEPROMs at home, but I haven’t had time to play with them yet. It looks like this is good material for a guide to be posted here.

i won’t have the I2C port on
i won’t have the I2C port on the picaxe 08M or 14M. These EEPROMs support both I2c and serial, so i was looking forward to a serial connection.

I2C is a serial protocl. If
I2C is a serial protocl. If your chip doesn’t support it natively, you have to code it yourself. This is sometimes called bit-banging. Google for “picaxe i2c bit-bang”.

aah ok i see. But then why

aah ok i see. But then why do some Picaxes have “i2c pins” (as listed in the schematics) and some others just have serial in and serial out pins (the one that go to the stereo jack)?

Anyways say i’ll be using bit banging, do you have idea of where i am going to stick those pins from the EEPROM memory? (since my current i2c port only has 3 pins)

The picaxes with i2c pins

The picaxes with i2c pins has commands to take care of sending the start/stop sequences and handling the timing.

I think you can use any I/O pins, since it’s a matter of setting/resetting the pins in the right order. A did a google search and found http://www.phanderson.com/picaxe/ds1624_28x.html. Maybe you can use that as inspiration.

that sounds really hard…
that sounds really hard…

yup! better get an 'X’
yup! better get an ‘X’ picaxe that has i2c build in. :slight_smile:

i think you are right, only
i think you are right, only reason i wanted the “M” series was because of the infraout. i guess i’ll just figure out how to modulate an IR, that sounds simpler

You can take a look at
You can take a look at http://www.societyofrobots.com/member_tutorials/node/35 if you still want to know about I2C.

Seriously, take a look at
Seriously, take a look at the manuals for the picaxe, I think there is code in there to do what you want. due to memory constraints thoughif you are using an 8m, it could be tight because the functions take up about half the memory. I beleive the info is in the shift in and shift out commands. they don’t work on the 8m/14m/ maybe 18x…but again…they have code to do the actual functions. I was going to try it myself, but ended up not doing it due to the whole memory issues…I have some 16lc256(I thnk thats the number)memory chips that I had considered using for memory storage as well…

There is something

There is something completely wrong here. Sorry, I do not have the time to get 100% into the case right now, but here are some “I am pretty sure”'s:

  • Any Picaxe supports I2C… and, but!:
  • When writing to/from EEPROM’s with Picaxe, you want to use some of the commands dedicated to it in the Picaxe library - “EEPROM” and “DATA”…

From my understanding, the

From my understanding, the eeprom/data command are for the internal eprom…I believe the OP was mentioning an external memory chip.

Not all of the PICAXE chips appear to support the spiin/spiout (aka shiftin/shiftout) commands, hence my reason to point out the manual has documention for sub procedures that should do a similar job for those chips that don’t support them. Page 156 of the picaxe manual(commands) mentions this and specificly states spi enabled eeprom memory. I wouldn’t say I’m completely wrong…yes/no?

 

eeprom and data are only for

eeprom and data are only for internal memory, yes.

i’ll check the spi/shift and the other sub procedures, and see if i can get something useful out of it :slight_smile:

PIC vs PICAXE

PICs tend to have a lot of functionality built in which isn’t all supported by PICAXE. Also, you know the way a lot of the pins on a PICcan have multiple functions?

The PIC containing the PICAXE bootloader may support I2C natively, but the PICAXE may not. It may use the I2C pins just for digial I/O or whatever.

Even if you don’t really understand teh PIC native RISC assembler, it’s worth scouring the Microchip website. They have code on there for making a regular I/O port into a I2C port by bit-banging. Be warned: it looks really complicated at first, but once you have some good, solid routines, it will work for you

I can’t help you with the PICAXE specific bits, but I’ve done this in RISC assembly and it was well worth the experience. If you have the patience, a good route mightbe to go with RISC assembler instead of BASIC. That way, you can let the PIC hardware take care of all the hard stuff.