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

Moway pic16f876a with telosb mote

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



Joined: 10 Jan 2011
Posts: 13

View user's profile Send private message

Moway pic16f876a with telosb mote
PostPosted: Mon Jan 10, 2011 8:55 am     Reply with quote

Hello guys. First post in here. For educational purpose I must connect a wireless sensor mote with the moway robot that works with pic16f876a. The mote has msp430 microprocessor. The moway robot connects with tue motor which is another pic processor with i2c bus. Master the robot slave the motor. My problem follows:
The mote has i2c bus but it can only work (as far as I know) only as master mode. Can I have both master and slave mode on the robot? I want the mote to send something (an integer with the mote master) and after that I want the robot to send to motor to do the move!

Can I do that?;)
Thanks in advance!
Stelios
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon Jan 10, 2011 10:04 am     Reply with quote

On a PIC, you can have as many I2C buses as I/O pins/2. _Only_ the hardware pins can be a slave though. Key is that a I2C 'slave', _must_ record each bit as it arrives, and respond with ACK or NACK, on the ninth bit of the packet. Only the hardware can guarantee to do this in the timescales needed. However you can implement a software 'master' on any other pins you have available, and this can happily send commands to the motor. This is where the 'stream' parameter comes in on #use I2c. You setup one I2C configuration using the hardware pins, programmed as a slave, and a second using another pair of pins configured as a master. The I2C transactions have to have the stream 'name' added, so they know which pins to use, and "Robert's your parent's brother"....

Best Wishes
stelios1988



Joined: 10 Jan 2011
Posts: 13

View user's profile Send private message

PostPosted: Mon Jan 10, 2011 10:24 am     Reply with quote

Thanks for the fast reply.
So I must learn how to use the #use i2c correctly and this can be done?
stelios1988



Joined: 10 Jan 2011
Posts: 13

View user's profile Send private message

PostPosted: Mon Jan 10, 2011 12:00 pm     Reply with quote

The pic16f876a has only 2 SDA/SCK output pins. So the option I have is to share the pins for slave/master mode. Can I do that?
Stelios
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon Jan 10, 2011 3:17 pm     Reply with quote

No.
You need to use these pins for the slave, and _any other pins you want_ for the master. You can have a second (or more) software master I2C, on _any_ pair of PIC I/O pins you want.

Best Wishes
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