[SPI .vs. I2C]
I use both regularly. SPI is inferior in some ways,
but superior in
I did say 'IMHO' :-).
others. I personally prefer I2C, but there are
situation in which SPI
is a better choice. It is MUCH faster (I2C tops out at 400KHz, I've
One bvious tiem to use SPI is if the chip you want only has an SPI
interfce :-).
seen SPI up in the several-MHz range), and I2C's
transfer size is fixed
True. It depends -- a lot -- on what uou are using it for. Most of the time
I use I2C to transfer small amounts of data to display drivers, low-speed
DACs, etc. It weorks fine for that.
I ssem to rememebr that SD cards implement a form of SPI. In which case
you have to use SPI for that.
at eight bits, while SPI can transfer arbitrary word
widths. (this is
handy for, say, ADCs and DACs).
Hmm.. I am nto convinced. Any microprocesosr/controller is goinf to have
a 'natural' word size (8 bits, 16 bits, etc). The hardware SPI interface
is goign to trasnfer in chunks of that size -- you write a byte, or
whatever to a particualr I/O register and it sends it (or part of it). If
you bit-bang it, you will be shifitng the data in one of the procesor
registers, again of a definted size.
So what I am sayign is that if you have an 8 bit processor and want to
talk to a 12 bit DAC, you are essnetially goign to ahve ot load 2 bytes
into the SPI interface. It may only send 4 bits of one of said bytes, of
course. That;'s no better or worse than having to send 2 bytes to an I2C
interface .
I2C, however, uses in-band addressing so it saves board space and I/O
pins over SPI.
YEs, that;'s the main reason I think it's more elegant. The separate chip
selects ot each SPI device are somethign fo a pain.
So, while I personally prefer I2C, I believe it is
incorrect to
consider SPI to be inferior, since it they both have their strengths and
weaknesses. The industry agrees, as both have been around for decades
and are still considered de-facto standards for local low-speed
communications. (I first used I2C on a Philips 87C751 microcontroller on
a gov't related project in 1991, and it was well-established even then!)
About when I was using it to talk to Philips teletext ICs, etc :-)
-tony