Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I2c protocol between 3 microcontroller

Status
Not open for further replies.

hodahussein

Full Member level 2
Joined
Apr 17, 2007
Messages
144
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,276
dear all



i want to do communication link between 3 micro-controller. i will depend on I2C . one of them will be master and other slaves. so the master will connect to first slave and send and receive from it and the same for second slave

but till now i can not understand exactly I2C [configuration and the operation ].
how can i do it using I2C?
is I2C are suitable for this communication or not?

wait your reply for very importance
thanks
 

hi

why don't you use serial communication
it is easy to use and all controllers can communicate with others.the distance also good

ml
 

your controller should support I2c protocol.. you just cant take any controller and do I2c... for e.g atmel 89 series dont support i2c protocol inbuilt. you need to go for philips that has i2c engine inside ...

you need i2c engine to be present in the slave device if you need to do communication... So first find out if your controller has this support else change the controller or change the method to some other protocol.....
 

hi ckshivaram

already i will use pic16f877 this micro controller has built in i2c, so i want to implement master slave communication

wait your reply
thanks
 

you use the SSPM3:SSPM0 bits of the pic16f877 SSPCON:sync serial port control register to select I2C master or slave mode. You program one of the pic16f877 as master the others as slaves
 

ok

i have many question
firstly assume taht we have three slave and one master
1- let me assume this example : if master need to talk to first slave so it will send the proper address on bus after start condition done the the match address will send ACK to master . is the other slaves send NACK on the same time. is this right or not?
2- how can slave sense if the master want to talk to it ? is this by interrupt or what?

wait your reply
thanks
 

1- let me assume this example : if master need to talk to first slave so it will send the proper address on bus after start condition done the the match address will send ACK to master . is the other slaves send NACK on the same time. is this right or not?
You can also say, the other slaves will ignore the communication, because they aren't adressed. Sending NACK is another word for doing nothing.
2- how can slave sense if the master want to talk to it ? is this by interrupt or what?
You mean, how the program running on the slave gets aware of it? Yes, interrupt would be an effective means. Alternatively, the program has to poll the respective status bit. It's important, that the slave software services the I2C interface in time.

P.S.: I suggest to read paragraph 9.4.3 Slave Mode of the PIC18F877 data sheet thoroughly. If gives a detailed description of how the slave works. You should also read about the clock stretching option, that allows to make the master wait for the slave processing each sent data byte.
 
Last edited:

HI

now i written the I2c firmware for master and slave depend on pic16f877 from microchip:
about master i see that initiate the connection with start condition and the send slave address i want to talk to it and then read or write some byte of data to it and each time i send i will ACK send by slave .
about slave i will enable interrupt so when the interrupt occurs i will check the address so if it matched then i receive data

my question
1-on the master side : is should each time after i send address and first data byte restart the connection[by do start condition again] or not? [i mean after each byte sent to slave should do start condition again or not]
2- on the slave side : is each time the transmitter send to slave [address or byte] interrupt it or not? i mean that:
for example[the master send 6 byte to slave]
master initiate the connection so send the address to bus so the matched slave reply with ACK, in same time the master send read or write data to slave in same session so after each receiving process by slave , the slave interrupt again or not just one interrupt.
3- how can slave sense the connection is finished?
4- if i have 3 slave and one master so
the address for 3 slave will be 0x02,x04,0x08. if master send 0x02 to bus so the first slave is matched , how can i know it by compare the content of SSPBUF with the value of address or what?
about mismatched slaves what will it do? if it interrupted each time master send to first slave or not?





wait your reply for importance
best regards
 
Last edited:

1.The master sequence to send data is:
-start
-write address
-one or more data bytes
-stop

2. The slave will be at least interrupted for each data byte, you can enable additional interrupts if you want. Read the PIC data sheet.
3. If the slave need to know when the stop condition is send, it can sense it by status bit and possibly enable an interrupt
4. Not addressed slaves don't need to act anyhow and e.g. won't get interrupts
 

hi FvM

ok i will do that
but what you mean with " you can enable additional interrupts if you want". allready i enabled the SSPIE for I2C
is there other interrupt related with I2C

wait your reply
thanks
 

Review the datasheet for the features to enable different interrupt causes in SSPCON1 and SSPCON2.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top