Pages

Tuesday, April 23, 2013

Comparing I2C to SPI notes


I quickly skimmed through wiki's articles on I2C and SPI, and jumped to the conclusion that SPI is much better than I2C for hobbists making DIY toys.


I2C - Wikipedia

...

I²C uses only two bidirectional open-drain lines, Serial Data Line (SDA) and Serial Clock (SCL), pulled up with resistors. ...

The I²C reference design has a 7-bit or a 10-bit (depending on the device used) address space.

...

Limitations

The assignment of slave addresses is one weakness of I²C. Seven bits is too few to prevent address collisions between the many thousands of available devices, and manufacturers rarely dedicate enough pins to configure the full slave address used on a given board. Three pins is typical, giving only eight choices of slave address. 


While some devices can set multiple address bits per pin,[7][8] e.g., by using a spare internal ADC channel to sense one of eight ranges set by an external voltage divider, usually each pin controls one address bit. Manufacturers may provide pins to configure a few low order bits of the address and arbitrarily set the higher order bits to some value based on the model. This limits the number of devices of that model which may be present on the same bus to some low number, typically between two and eight. That partially addresses the issue of address collisions between different vendors. 

Ten-bit I²C addresses are not yet widely used, and many host operating systems do not support them.[9] Neither is the complex SMBus "ARP" scheme for dynamically assigning addresses (other than for PCI cards with SMBus presence, for which it is required).

Automatic bus configuration is a related issue. A given address may be used by a number of different protocol-incompatible devices in various systems, and hardly any device types can be detected at runtime. For example 0x51 may be used by a 24LC02 or 24C32 EEPROM, with incompatible addressing; or by a PCF8563 RTC, which cannot reliably be distinguished from either (without changing device state, which might not be allowed).

The only reliable configuration mechanisms available to hosts involve out-of-band mechanisms such as tables provided by system firmware which list the available devices. Again, this issue can partially be addressed by ARP in SMBus systems, especially when vendor and product identifiers are used; but that has not really caught on. The rev 03 version of the I²C specification adds a device ID mechanism, which at this writing[when?] has not had time to catch on either.

...


SPI - Wikipedia 

...

... a synchronous serial data link standard, ... that operates in full duplex mode. Devices communicate in master/slave mode where the master device initiates the data frame. Multiple slave devices are allowed with individual slave select (chip select) lines.


Pros and cons of SPI

Advantages

Full duplex communication

Higher throughput than I²C or SMBus

Complete protocol flexibility for the bits transferred

Not limited to 8-bit words

Arbitrary choice of message size, content, and purpose

Extremely simple hardware interfacing

Typically lower power requirements than I²C or SMBus due to less circuitry (including pull up resistors)

No arbitration or associated failure modes

Slaves use the master's clock, and don't need precision oscillators

Slaves don't need a unique address — unlike I²C or GPIB or SCSI

Transceivers are not needed

Uses only four pins on IC packages, and wires in board layouts or connectors, much fewer than parallel interfaces

At most one unique bus signal per device (chip select); all others are shared

Signals are unidirectional allowing for easy Galvanic isolation ???

Not limited to any maximum clock speed, enabling potentially high throughput


Disadvantages

Requires more pins on IC packages than I²C, even in the three-wire variant

No in-band addressing; out-of-band chip select signals are required on shared buses

No hardware flow control by the slave (but the master can delay the next clock edge to slow the transfer rate)

No hardware slave acknowledgment (the master could be transmitting to nowhere and not knowing it)

Supports only one master device

No error-checking protocol is defined

Generally prone to noise spikes causing faulty communication

Without a formal standard, validating conformance is not possible

Only handles short distances compared to RS-232, RS-485, or CAN-bus

Many existing variations, making it difficult to find development tools like host adapters that support those variations

SPI does not support hot plugging (dynamically adding nodes).

.END



Galvanic isolation - Wikipedia

Galvanic isolation is a principle of isolating functional sections of electrical systems to prevent current flow; no metallic conduction path is permitted. Energy or information can still be exchanged between the sections by other means, such as capacitance, induction or electromagnetic waves, or by optical, acoustic or mechanical means.

Galvanic isolation is used where two or more electric circuits must communicate, but their grounds may be at different potentials. It is an effective method of breaking ground loops by preventing unwanted current from flowing between two units sharing a ground conductor. Galvanic isolation is also used for safety, preventing accidental current from reaching ground through a person's body.

Methods

...

Transformers couple by magnetic flux. ...

Optocouplers transmit information by light waves. The sender (light source) and receiver (photosensitive device) are not electrically connected ...

Capacitors allow alternating current (ac) to flow, but block direct current; they couple ac signals between circuits at different direct voltages.

...

.END



No comments:

Post a Comment