I2C vs SPI

Started by Paul March 16, 2009
Hi. Just been looking at I/O Expanders from Microchip, and you can get them in either I2C or SPI. The only differences i can see are SPI can go faster, and I2C uses less pins. Is that about it?

Thanks,
Paul

SPI:
master + slaves
3wire
simple code
high speed
'few' peripheral devs

I2C:
multi master + slaves
2wire
complicated code
low-medium speed
'many' peripheral devs
Paul skrev:
>
> Hi. Just been looking at I/O Expanders from Microchip, and you can get
> them in either I2C or SPI. The only differences i can see are SPI can
> go faster, and I2C uses less pins. Is that about it?
>
> Thanks,
> Paul

--
*******************************************
VISIT MY HOME PAGE:

LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen
Also:

> SPI:
> master + slaves
> 3wire
> simple code
> high speed
> 'few' peripheral devs
Needs 1 enable line per peripheral in addition to three lines.

>
> I2C:
> multi master + slaves
> 2wire
> complicated code
> low-medium speed
> 'many' peripheral devs
Peripherals have addresses, does not need enable lines.
> Paul skrev:

I like SPI because it is largely clock jitter tolerant and is easily
bit-banged. I2C can be bit banged too, but because it uses priority,
packets, arbitration code, etc. it's way more complex.

DLC

>>
>> Hi. Just been looking at I/O Expanders from Microchip, and you can get
>> them in either I2C or SPI. The only differences i can see are SPI can
>> go faster, and I2C uses less pins. Is that about it?
>>
>> Thanks,
>> Paul
>>
>> --
> *******************************************
> VISIT MY HOME PAGE:
>
> LAST UPDATED: 23/08/2003
> *******************************************
> Regards
> Eirik Karlsen
--
Dennis Clark
TTT Enterprises

> I like SPI because it is largely clock jitter tolerant and is easily
> bit-banged. I2C can be bit banged too, but because it uses priority,
> packets, arbitration code, etc. it's way more complex.

Unless you want to use multiple masters you can forget about most of
those complexities. And most slaves don't stretch the clock.

--

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu

> Hi. Just been looking at I/O Expanders from Microchip, and you can get
> them in either I2C or SPI. The only differences i can see are SPI can go
> faster, and I2C uses less pins. Is that about it?
>
> Thanks,
> Paul

Every time I do I2C, I have to get out the logic analyzer and try to
figure out what I did wrong. Does it need a second start? What about ACK,
NAK, or whatever? SPI just works, and is MUCH faster.

Harold
--
FCC Rules Updated Daily at http://www.hallikainen.com - Advertising
opportunities available!
Thanks for the replies guys, will have a think and a play to see which i prefer

Paul
From: Paul
Sent: Monday, March 16, 2009 7:37 PM
To: p...
Subject: [piclist] I2C vs SPI
Hi. Just been looking at I/O Expanders from Microchip, and you can get them in either I2C or SPI. The only differences i can see are SPI can go faster, and I2C uses less pins. Is that about it?

Thanks,
Paul
One more thing to consider if you are thinking to use the I2C in harsh
environment (car, CNC etc..) ==> It can "hang"..

Met

----- Original Message -----
From: Paul Laverick
To: p...
Sent: Tuesday, March 17, 2009 5:21 PM
Subject: Re: [piclist] I2C vs SPI

Thanks for the replies guys, will have a think and a play to see which i
prefer

Paul
From: Paul
Sent: Monday, March 16, 2009 7:37 PM
To: p...
Subject: [piclist] I2C vs SPI
Hi. Just been looking at I/O Expanders from Microchip, and you can get them
in either I2C or SPI. The only differences i can see are SPI can go faster,
and I2C uses less pins. Is that about it?

Thanks,
Paul
--- In p..., "Paul" wrote:
>
> Hi. Just been looking at I/O Expanders from Microchip, and you can get them in either I2C or SPI. The only differences i can see are SPI can go faster, and I2C uses less pins. Is that about it?
>
> Thanks,
> Paul
>

It's true the SPI is MUCH faster but only if the circuit layout can handle the high frequency. I usually try to keep my SPI stuff around 10 MHz.

I2C generally maxes out around 400 kHz.

Code for the I2C state machine is complex. Most incantations don't deal with bus hang.

Many uCs have SPI gadgets and the code is quite simple.

Given the choice, I would always choose SPI.

Richard

Hi.

I was thinking the same about SPI

Cheers,
Paul
From: rtstofer
Sent: Friday, March 20, 2009 3:35 AM
To: p...
Subject: [piclist] Re: I2C vs SPI
--- In p..., "Paul" wrote:
>
> Hi. Just been looking at I/O Expanders from Microchip, and you can get them in either I2C or SPI. The only differences i can see are SPI can go faster, and I2C uses less pins. Is that about it?
>
> Thanks,
> Paul
>

It's true the SPI is MUCH faster but only if the circuit layout can handle the high frequency. I usually try to keep my SPI stuff around 10 MHz.

I2C generally maxes out around 400 kHz.

Code for the I2C state machine is complex. Most incantations don't deal with bus hang.

Many uCs have SPI gadgets and the code is quite simple.

Given the choice, I would always choose SPI.

Richard
SPI is much easier to write by yourself (bit bang) without any special hardware IO port, it's quite easy in fact, search wikipedia. So I would suggest the I2C expander if you want to buy one, so you don't have to handle all the details with I2C. Although I don't know what software is required to handle the I2C even if you have a port.
BasicPoke

--- In p..., "Paul" wrote:
>
> Hi. Just been looking at I/O Expanders from Microchip, and you can get them in either I2C or SPI. The only differences i can see are SPI can go faster, and I2C uses less pins. Is that about it?
>
> Thanks,
> Paul
>