inexperienced EEPROM address question.

Hi,
I have nt used I2C before and need someone to help! I have connected two EEPROMS 24LC256

My question is quite naive. How do I address them and and what part do the pins A0,A1,A2 play. What part does the unique address that is built in at time of manufacture and how does that assist me ?

The first EEPROM has all A0,A1,A2 pulled to ground. I think its addressed at 000 ??????

I have the second EEPROM connected to SCL and SDA and the pin A0 is pulled high because I think it must be hardwired unique on pins A0,A1,A2.

Am I correct ? What would the address of the second EEPROM be ?????????

Thanks.:eek:
 

MPep

Senior Member
A0, A1, A2 are indeed for having multiple identical ICs on the bus. For 3 lines, 2 to the power of 3 = 8 ICs max. In the data sheet, there is normally reference to the address, and the A0 - 2 range is normally incorporated within that.
Have just downloaded the data sheet. In the 28pages, you need to look on page 7.

Hope this helps.
MPep.
 

westaust55

Moderator
i2c EEPROM address question.

You are on the right path.

As you mention EEPROMs such as the 24LC256 have an address comprising three parts:
1. the device type specific = 4 bits = $1010
2. the hardware defined part = 3 bits = a2,a1,a0
3. and the read/write bit = 1 bit == which we can always leave as 0 since the PICAXE BASIC will toggle this bit to suit the actual command used.

Putting these all together, we have %1010aaa0

So if you have a2, a1 and a0 all tied to 0v then the total slave address for the EEPROM is: %10100000

For an EEPROM with the a0 line pulled high, the total slave address for the EEPROM is: %10100010
 
Last edited:
ta

thanks westaust55 &
MPep

I read the datasheet and the %1010aaa0 explanation was very helpfull. I was reading the picaxe manual for more clarification on how to use an eeprom.

Manual only mentions three i2c commands
I2CSLAVE, READI2C, WRITEI2C. hOWEVER,, the example code I found to configure a 24LC256 eeprom is

i2cslave %10100000, i2cfast, i2cword:confused:
 

kewakl

Senior Member
Manual only mentions three i2c commands
I2CSLAVE, READI2C, WRITEI2C. hOWEVER,, the example code I found to configure a 24LC256 eeprom is

i2cslave %10100000, i2cfast, i2cword:confused:
Depending on the PICAXE used(X1,X2) , check out the HI2CIN, HI2COUT,HI2CSETUP instructions.
 

westaust55

Moderator
thanks westaust55 &
MPep

I read the datasheet and the %1010aaa0 explanation was very helpfull. I was reading the picaxe manual for more clarification on how to use an eeprom.

Manual only mentions three i2c commands
I2CSLAVE, READI2C, WRITEI2C. hOWEVER,, the example code I found to configure a 24LC256 eeprom is

i2cslave %10100000, i2cfast, i2cword:confused:
i2cslave %10100000, i2cfast, i2cword
will setup the PICAXE for i2c comms to your EEPROM

then you need to use the other commands to read from and write to the EEPROM.

to write to a memory locations you need:
writei2c location, (data1, data2, data3, data4, . . . )

For the 24LC256, the location needs to be either a word variable or a constant. A byte variable will only access the first 256 memory locations ($00xx).

you can have as few as 1 or for sequential page writes as many data values (to a max of 64 bytes) as you want. They can be variables or constants, so the following is valid

writei2c $1022, (b0, b1, b2, $55, $AA, $FF )
note you can use decimal or binary instead of the hex values in the above.

readi2c is exactly the same format as writei2c.


Also for your future reference:
1. if you also use other i2c devices of different types, then you need to issue the setup i2cslave command before each new device type is first accessed.
2. when writing multiple bytes of data at one time (called page writing), the EEPROM stores the data in a temp register and then transfers the data to the EEPROM once the data is all received. This takes a short time and it is good practice to have a PAUSE 10 after such writei2c commands
 
Last edited:

cactusface

Senior Member
EEPROM???

Hi Folks,
Just want to say thanks, I posted a similar thread a few days ago, with just the same problem with adding an EEPROM to my current project. If anything I was mislead by the manual, thinking I could only address 256 (8 bit address) locations direct and the others on pages!! But now I seem to have it sorted.

My Picaxe test-bed is now working in a very basic way, in that I'v stuck my 40X2 in and can run a simple LED flashing program, still have to add my LCD display, DS1307 RTC and DS18B20 temp and test it all, more later, when my backs feeling better after all that soldering.....;);)

Regards
Cactus
 
Top