View previous topic :: View next topic |
Author |
Message |
Ringo42
Joined: 07 May 2004 Posts: 263
|
Choosing I2C master or slave at runtime |
Posted: Tue Jun 26, 2007 11:01 am |
|
|
Is it possible to set I2C master or slave at runtime?
Can I say?
if(x)
#use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C3, address=0x50)
else
#use i2c(Master, SDA=PIN_C4, SCL=PIN_C3, address=0x50)
I've tried this sort of thing using the Baud rate for a Use232 command and it would not work, but then I found out how to change the baud rate on the fly. Is there something similar for I2C? I want to have several identical boards and a jumper so that when the board boots it looks at the jumper and decides if it is master or slave.
Thanks
Ringo _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 26, 2007 12:54 pm |
|
|
The library code isn't re-configurable between Master or Slave mode
at runtime. |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Tue Jun 26, 2007 1:40 pm |
|
|
I've never tried this but it might be possible to set them up as a Multi-Master system. Each one would be able to take turns as a master. I'm not sure, however, if they would be able to act as a Slave when they're not acting as a master. Opinions anybody???
Ronald
Edit:
I'm wondering if you would be able to manipulate bits SSPM<3:0> in the SSPCON register to switch between Master and Slave modes. |
|
|
|