CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Choosing I2C master or slave at runtime

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

Choosing I2C master or slave at runtime
PostPosted: Tue Jun 26, 2007 11:01 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 26, 2007 12:54 pm     Reply with quote

The library code isn't re-configurable between Master or Slave mode
at runtime.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Tue Jun 26, 2007 1:40 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group