Multiple i2c Devices

tjetson

Senior Member
Hi

I have the Picaxe 18X and want to use an RTC plus an EEPROM chip. I couldn't find any mention to multiple i2c devices in the manuals. Then I found some code which simply used the i2cslave command again whenever it wanted to talk to a different device. Is this how I would do it?

To put it another way, some mock code:

Code:
main:
i2cslave (rtc address, etc)
readi2c (rtc)

i2cslave (eeprom address, etc)
readi2c (eeprom)
 

tjetson

Senior Member
I had in fact read this previously and couldn't find the info I wanted. The closest I could find was on page 6, Reading Data section.
 

westaust55

Moderator
To expand upon what BB has stated,


it also depends upon which PICAXE chip you have.

the X chips (18X, 28X, 40X) need to follow your proposal - I note that it is an 18X you current are enquiring about


but for the X1/X2 chips, you only need a new i2cslave command each time you wish to communicate with a different type of device.

For example if you have a couple of EEPROMs or an EPROM and a F-RAM chip, then a single i2cslave command for the memory chips will suffice.

So you could have

HI2CSETUP 12cslave, %1010aaa0, i2cfast, i2cword

where aaa is the address of the device set typically by the hardware address pins,

then for each of those memory devices include the [newslave] part as:

HI2CIN [newslave],location,(variable,...)

where newslave is the %1010aaa0) part specific to the memory chip you wish to address.
 
Top