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 support@ccsinfo.com

i2c Multi-Slave

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



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

i2c Multi-Slave
PostPosted: Sun Jun 20, 2004 4:33 am     Reply with quote

Hi:
anybody knows how many PIC's can I connect into the i2c bus in multi-slave mode ? Shocked

Which Output Capacitance has a PIC in i2c mode ( with and without hardare implementations ) ? Rolling Eyes

Regads;

Joan.
_________________
I Came. I Saw. I Won.
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

Numer of I2C devices
PostPosted: Sun Jun 20, 2004 7:44 am     Reply with quote

According to the Phillips I2C bus specification at:

http://www.semiconductors.philips.com/buses/i2c/

I quote:

The number of devices that can be connected to the same
bus is limited only by a maximum bus capacitance of
400 pF.

But the distance is very limited compared to RS232 or RS422.

Capacitance of each device is determined by a number factors and can vary:

1. What type of connections, PC trace, discrete wiring, ribbon cable or ...
2. distance between SDA and SCL conductors
3. distance between devices
4. size of conductors etc.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Sun Jun 20, 2004 9:48 am     Reply with quote

If you were to utilize bus expanders(buffers) you could probably have devices up to the number of addresses available.
Guest








PostPosted: Sun Jun 20, 2004 10:17 am     Reply with quote

Hi:
the exact case is the following. I have 3 PIC16F88 ( 1 Master, 2 Slaves [adress_slave_1=0xa0], [adress_slave_2=0xa1] ).

I'm trying to

write to Slave_1;
delay_ms (500);
write to Slave_2;
dalay_ms (500);

But I can't.

If I only connect Slave_1 to bus all works. If I only conect Slave_2 to bus all works. But if I connect both Slave_1 & Slave_2 to bus it doesn't works. I thought it was possible to be the total bus capacitance.

I had seen that line SCL=1 and SDA=0 when It is delaying_ms(500).

Any Ideas? Shocked

Joan.
Joan



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Sun Jun 20, 2004 10:23 am     Reply with quote

Anonymous wrote:
Hi:
the exact case is the following. I have 3 PIC16F88 ( 1 Master, 2 Slaves [adress_slave_1=0xa0], [adress_slave_2=0xa1] ).

I'm trying to

write to Slave_1;
delay_ms (500);
write to Slave_2;
dalay_ms (500);

But I can't.

If I only connect Slave_1 to bus all works. If I only conect Slave_2 to bus all works. But if I connect both Slave_1 & Slave_2 to bus it doesn't works. I thought it was possible to be the total bus capacitance.

I had seen that line SCL=1 and SDA=0 when It is delaying_ms(500).

Any Ideas? Shocked

Joan.


I don't remember to Log-in Embarassed

Joan
_________________
I Came. I Saw. I Won.
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

I2C slaves
PostPosted: Sun Jun 20, 2004 10:43 am     Reply with quote

How far apart are they and how are they connected to the master?
Guest








PostPosted: Sun Jun 20, 2004 1:05 pm     Reply with quote

Hi:

about your questions, one Slave is connected on the same protoboard that Master is ( about 5cm ). The Second Master is at 15 cm aprox.
in another protoboard.

Both are connected with 2 pull-up resistors of 2k7 Ohms in the SDA and SCL lines. ( I also try with 10k Ohm but doesn't works ).

Regards;

Joan
Joan



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Sun Jun 20, 2004 3:25 pm     Reply with quote

Hi:
I've inserted a little code into the interrupt i2c routine that send to RS-232 the data that pic is receiving from i2c bus. That's the result:

With 2 Slaves connected to bus instead the command I'd send

write_i2c (0x0a);
write_i2c(5);
delay_ms(500);

write_i2c(0xa1);
write_i2c(5);
delay_ms(500)

The Slave_1 [adress_slave_1=0xa0] receive

0x41
0x0b

0x43
0x0b

When I disconnect one of the 2 PIC's the data received by the Slave is:

0xa0
0x05

0xa1
0x05

Obviously the connection of the second slave loads the bus changing the data that master transmits, but why?

Regards;

Joan
_________________
I Came. I Saw. I Won.
Joan



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Sun Jun 20, 2004 4:08 pm     Reply with quote

Hi:
Problem solved. The question is about delay_cycles():
Next to interpreting the bad results versus the good results:

[0xa0] -> 10100000 [0x41] -> 01000000
[0x05] -> 00000101 [0x0b] -> 00001011

[0xa1] -> 10100001 [0x43] -> 01000011
[0x05] -> 00000101 [0x0b] -> 00001011

I thought that the questions is a bit shifting .. so I've inserted the red lines:

i2c_start(); // Start condition
delay_cycles( 24 );
i2c_write(0xa0); // Device address
delay_cycles( 24 );
i2c_write(5); // Write Command
i2c_stop();

And that's all. I don't know why this aditional delay is needed when there are more that 1 slave conneted into the i2c bus. But it works for me.

The problem is solved, but anybody knows why this occurs?

Best Regards;

Joan. Idea
_________________
I Came. I Saw. I Won.
akiashiba



Joined: 20 Jun 2004
Posts: 2

View user's profile Send private message

PostPosted: Mon Jun 21, 2004 7:53 am     Reply with quote

Code:
the exact case is the following. I have 3 PIC16F88 ( 1 Master, 2 Slaves [adress_slave_1=0xa0], [adress_slave_2=0xa1] ).


Perhaps, you make some wrong add here.

The first bit0 is R/W bit of each slave address. So, each time you send the address of slave2, it will know that it's the slave1 at READ mode. And you cannot write to the slave 2

Try with slave1_add = 0xa0 and slave2_add = 0xb0

I'm not familiar with CCS C, but I know it is wrong addresses for 2 slave. I'm sure.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Mon Jun 21, 2004 8:53 am     Reply with quote

You can't have an address of 0xA1. The LSB of the address bit is the R/W bit for the command word. You need to have 0xA0, 0xA2, 0xA4, 0xA6 and so on for addresses. The Slave that is at address 0xA0 will have the command 0xA0 sent to it indicating that data will be written to it. An address of 0xA1 will tell the Slave that data will be read from it.

So, if the second Slave is at address 0xA2, sending a 0xA2 will be writing data to it and an address of 0xA3 will be reading data from it.

Clear as mud?

Ronald
Joan



Joined: 29 May 2004
Posts: 41
Location: Barcelona, Spain

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Mon Jun 21, 2004 11:20 am     Reply with quote

Hi guys:

I'd proved with these 2 options:

slave_adress_1=0xa0;
slave_adress_2=0xa2;

and next with

slave_adress_1=0xa0;
slave_adress_2=0xb0;

and woks too. But if I delete the lines with delay_cycles(); they don't work.

Yes, the slave_adress_2 can't be 0xa1, but changing it by 0xa2 or 0xb0 I can't solve the thing that the info I've send to i2s bus change misteriously.

Regards;

Joan Shocked
_________________
I Came. I Saw. I Won.
falleaf



Joined: 23 May 2004
Posts: 48

View user's profile Send private message

PostPosted: Tue Jun 22, 2004 1:49 pm     Reply with quote

hi,

I also don't understand about this. I tried with mike's i2c examples, and I can tx to the slave with ease, but I cannot read from it. I don't know why.

I simply get start condition and call i2c_read(). It's good if I use only one buffer, but as I use more than 1 byte buffers, the results get wrong.

see in "Need i2c examples" thread.

Thanks muchie.
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