View previous topic :: View next topic |
Author |
Message |
stelios1988
Joined: 10 Jan 2011 Posts: 13
|
Moway pic16f876a with telosb mote |
Posted: Mon Jan 10, 2011 8:55 am |
|
|
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: 19552
|
|
Posted: Mon Jan 10, 2011 10:04 am |
|
|
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
|
|
Posted: Mon Jan 10, 2011 10:24 am |
|
|
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
|
|
Posted: Mon Jan 10, 2011 12:00 pm |
|
|
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: 19552
|
|
Posted: Mon Jan 10, 2011 3:17 pm |
|
|
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 |
|
|
|