General area when it fits no where else

Moderator: Mmiscool

User avatar
By PhilTilson
#63932 I have successfully used I2C to communicate between a μP and a RTC or an EEPROM, but I now need to talk between an ESP and a PIC18F2321. Both offer I2C capabilities but I'm a bit baffled about addresses.

In the case of EEPROM or RTC, they have defined addresses which I can use in the I2C setup. However, how do I assign an address to my 'slave' μP? There doesn't seem to be any command in the ESPbasic set to do this, and I can't find anything in the software I am using on the 18F2321 either.

The PIC will be the slave and the ESP the master.

What am I missing here?!

Phil
User avatar
By heckler
#63941 Hi Phil,

Are you planning on having more than one device on the I2C buss?
If not then could you ignore the requirement for using an address?
What language are you using to code the PIC.
As I look in my PICBASIC manual it shows the I2C address as optional. I assume that the address is only required if there are more than one device on the I2C buss.

regards
dwight
User avatar
By PhilTilson
#63945 martinayotte -
In your PIC Slave code, it must provide an address when it register as slave. - See more at: viewtopic.php?f=45&t=14201&sid=47c67c510edadcbd4e63a9c34e11a415#sthash.PoX1Wd1U.dpuf

The problem is that this capability is provided as part of the Arduino library. The software I am using (PICbasic) does not have this capability!

heckler - No, only one slave on the bus. I am not sure what version of PICbasic you have, but in mine (v3.39) it says: "The third argument of both statements [I2CWRITE and I2CREAD] must be a constant value or Byte variable called 'slave address'. I wasn't aware that it was possible to send/receive I2C data without specifying an address.

Apparently, in the Arduino library, there is a command that allows you to set a slave address in another Arduino. I was hoping there was something similar for the PIC!

Phil