Searching \ for '[PIC]: I2C master and slave modes' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/i2cs.htm?key=i2c
Search entire site for: 'I2C master and slave modes'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: I2C master and slave modes'
2001\03\30@082229 by Ronald Cotton

flavicon
face
First, I am sorry if this is a double post.

Next, I have a question about the I2C master and slave modes.

I know that a slave device requires a unique address and I think that I
understand the process of reading and writing data to and from a device;
however, I have a bit of confusion concerning whether an address is
required.


If a slave device has an address of 5, is this address the first item
written to the I2C bus?  What distinguishes the address of the device from
the address within the device?

In using interrupts, I know that an interrupt will be generated if the
address(address of device) on the bus matches my device.



The PIC in question is the 16F877.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\03\30@090109 by Drew Vassallo

picon face
>I know that a slave device requires a unique address and I think that I
>understand the process of reading and writing data to and from a device;
>however, I have a bit of confusion concerning whether an address is
>required.

If you have only one slave device on the bus, you can just address it as
0x00.  Depends on how you have the slave device's address pins configured
(typically all GND = 0x00 for one device).  On the 24C series, there are 3
chip select bits that you can use to configure up to 8 devices on one bus.
You can read/write to each of them independently through the use of these
chip select bits (addresses).

>If a slave device has an address of 5, is this address the first item
>written to the I2C bus?  What distinguishes the address of the device from
>the address within the device?

I think you're confusing the address of the device and the memory address
that you're writing to in the device.  If you have your slave configured as
"device number 0x05" (which you can only do on addressable memory devices,
keep in mind), you have to communicate to it through the bus by sending the
chip select bits (address bits) as part of the control word to the device
before you can transfer data.  Then, you send the memory location that you'd
like to read/write.

Have you actually looked at any datasheets for I2C devices??  I can assume
the answer is no because if you did, you'd realize very quickly how simple
it is to use these chips and how there is no confusion between the device's
address and the memory locations contained therein.  Check out the 24C02
datasheet from Microchip's website.  It outlines how to communicate to the
chip for read and write access.

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\03\30@120531 by Olin Lathrop

face picon face
> I know that a slave device requires a unique address and I think that I
> understand the process of reading and writing data to and from a device;
> however, I have a bit of confusion concerning whether an address is
> required.
>
> If a slave device has an address of 5, is this address the first item
> written to the I2C bus?  What distinguishes the address of the device from
> the address within the device?

I don't know what you mean by "address of the device" as apposed to "address
within the device".

Each IIC bus slave has a unique 7 bit (can also be 11 bit, but this would be
unusual in small systems) address.  The lines are wiggled in unique ways to
start a message and to end a message.  All slaves watch for these and
therefore know when messages start.  The first byte of all messages is sent
by the master, and contains the address of the slave that is supposed to
react to the message.  So again all slaves know when a new message starts
and who is being addressed.  After the first byte, all slaves except the one
that was addressed ignore the message.  The addressed slave responds with an
ACK.  If no slave was addressed then the bus lines are left floating during
the ACK bit, which is the NACK condition.  If the master gets an ACK it can
continue with the message.  If it gets a NACK, then it knows nobody is
listening and terminates the message.

The special slave address of 0 is the "general call" address.  This is for
broadcast messages.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, spam_OUTolinTakeThisOuTspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\03\30@140024 by Barry King

flavicon
face
Ronald,
I don't know if you realized that you replied off list to me directly.
>Thanks Barry, but the situation involves the use of 1 Master Pic and 4 other Pics.
-- Master's Address=0x01
-- Slave 1's Address=0x02
-- Slave 2's Address=0x03
and so forth.
>Let's assume that I want to write (data) 0xAA to location (address) 0x20:
--Master wants to talk to 1st slave Pic , write address 02 to I2C line
--Ack from slave
--Master sends address of location to be written to, write 0x20, for example
--Ack from slave
--Master sends data to be written to location 0x20, for example 0xAA
--Ack from slave
>In the above scenario, on the slave side, how does the slave know that the 2nd address sent by the
>master is address information and not data?

By the sequence.

First byte after Start is always slave address.  If it matches the slave's address, then all bytes from then
until stop are to (write) or from (read) that slave, in order.

In the PIC slave, there is a different flag for address match vs data bytes.  In your scenario, the first
data byte  is an internal address, the second data byte is the data.

-Barry.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\03\31@073750 by Alok Dubey (OCS-BLRAKS-AVS)

flavicon
face
as far as i am aware u have to send a stop b4 u switch to a new slave..


{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...