Re: SPI or I2C...

Started by Paul James E. April 27, 2004

All,

FWIW, I agree with Igor here. We have a system that we designed in house
for use in house, and we needed several peripheral chips we wanted to use.
One of the chips was perfect for our application and use an SPI interface.
We inteplemented this chip in our system. Another chip was also perfect
for our application, but it had an I2C interface. So we implemented that
one also. So in our system, we have I2C, SPI, RS232, and RS485. Just
about every popular (common) serial protocol used. Here we weren't really
concerned about cost so much as we were with the fact that it had to do
what we needed and wanted it to do. We accomplished our goal.
The bottom line from my perspective is use what you need. It may make
the software somewhat more difficult, but once you get it working, you can
use the software routines together or by themselves in other applications.

Just my 2 cents worth. Regards,

Jim >> As a group discussion, can anyone offer what they use, and why they
>> chose that ?
>
> Component selection and therefore serial interface selection depends
> entirely on application requirements.
>
> There is no such thing as universal perfect choice. One chip (or
> interface type) is perfect for one application but it's useless in
> other application. There are many parameters that need to be considered
> when making a choice. Sometimes SPI works better for your application
> and sometimes it's I2C. There are no general rules - just application
> specific solutions.
>
> I'll give you one example how obvious and logical rule can't be used
> because of specific application requirements:
>
> Rule:
> Use I2C only or SPI only so that software (and pcb) is easier to
> develop since you deal with only one type of communication. Sounds OK,
> right?
>
> Problem:
> You are trying to design low cost device and you can reduce cost only
> if you use I2C and SPI chips together since solution#1 is cheaper when
> it's I2C and solution#2 is cheaper when SPI is used. So, you choose one
> I2C chip (e.g. EEPROM) and one SPI chip (e.g. ADC) in order to reduce
> cost although it means more complex software. Having both chips as SPI
> type or as I2C type will increase cost.
>
> This is just example to show how complex decisions need to be made when
> working on a project and how general rules can't be used although these
> rules seem logical.
>
> Conclusion:
> SPI or I2C discussion makes sense only if you tell us details about
> your application...
>
> Regards,
> Igor >
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~--> Buy Ink Cartridges or Refill Kits for your
> HP, Epson, Canon or Lexmark Printer at MyInks.com. Free s/h on orders
> $50 or more to the US & Canada.
> http://www.c1tracking.com/l.asp?cidU11
> http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/dN_tlB/TM
> ---------------------------------~->
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions Yahoo! Groups Links >
>


Hi All, I've been discussing the different serial options and it seems that
most chips are available in SPI or I2C.

As a group discussion, can anyone offer what they use, and why they
chose that ?

It seems the the 3 wire is more common on chips like ADC's. But
memory seems divided pretty well.

Thanks in Advance.

Dave



Alle 17:51, marted27 aprile 2004, Dave Mucha ha scritto:

> I've been discussing the different serial options and it seems that
> most chips are available in SPI or I2C.
>
> As a group discussion, can anyone offer what they use, and why they
> chose that ?

I2C is a more complicated standard.
I use I2C when I need more than one/two peripheral connected to the bus (no
need of chip enables) or when I need to connect more microcontrollers
toghether (multimaster) or to connect complex peripherals (displays,...).

Usually I use SPI when I need to connect to one or two simple peripherals such
as ADC or DAC or small EEPROM.

If I have to choose one of them to be software implemented, then I choose to
implement the SPI by software and to use an hardware I2C. Regards,

Fausto

--
Fausto Marzoli - 8052.it - http://www.8052.it/



> As a group discussion, can anyone offer what they use, and why they
> chose that ?

Component selection and therefore serial interface selection depends
entirely on application requirements.

There is no such thing as universal perfect choice. One chip (or interface
type) is perfect for one application but it's useless in other application.
There are many parameters that need to be considered when making a choice.
Sometimes SPI works better for your application and sometimes it's I2C.
There are no general rules - just application specific solutions.

I'll give you one example how obvious and logical rule can't be used because
of specific application requirements:

Rule:
Use I2C only or SPI only so that software (and pcb) is easier to develop
since you deal with only one type of communication. Sounds OK, right?

Problem:
You are trying to design low cost device and you can reduce cost only if you
use I2C and SPI chips together since solution#1 is cheaper when it's I2C and
solution#2 is cheaper when SPI is used. So, you choose one I2C chip (e.g.
EEPROM) and one SPI chip (e.g. ADC) in order to reduce cost although it
means more complex software. Having both chips as SPI type or as I2C type
will increase cost.

This is just example to show how complex decisions need to be made when
working on a project and how general rules can't be used although these
rules seem logical.

Conclusion:
SPI or I2C discussion makes sense only if you tell us details about your
application...

Regards,
Igor



--- In , "Igor Janjatovic" <kodrat@p...> wrote:
> > As a group discussion, can anyone offer what they use, and why
they
> > chose that ?
>
> Component selection and therefore serial interface selection depends
> entirely on application requirements.
>
> There is no such thing as universal perfect choice. One chip (or
interface
> type) is perfect for one application but it's useless in other
application.
> There are many parameters that need to be considered when making a
choice.
> Sometimes SPI works better for your application and sometimes it's
I2C.
> There are no general rules - just application specific solutions.
>
> I'll give you one example how obvious and logical rule can't be
used because
> of specific application requirements:
>
> Rule:
> Use I2C only or SPI only so that software (and pcb) is easier to
develop
> since you deal with only one type of communication. Sounds OK,
right?
>
> Problem:
> You are trying to design low cost device and you can reduce cost
only if you
> use I2C and SPI chips together since solution#1 is cheaper when
it's I2C and
> solution#2 is cheaper when SPI is used. So, you choose one I2C chip
(e.g.
> EEPROM) and one SPI chip (e.g. ADC) in order to reduce cost
although it
> means more complex software. Having both chips as SPI type or as
I2C type
> will increase cost.
>
> This is just example to show how complex decisions need to be made
when
> working on a project and how general rules can't be used although
these
> rules seem logical.
>
> Conclusion:
> SPI or I2C discussion makes sense only if you tell us details about
your
> application...
>
> Regards,
> Igor


I do agree that there is not perfect choice, but like I had mentioned
I was wondering what is generally used, or one's first choice.

Ic2 for lower pin counts ?

SPI for easier software ?

I2C for tighter code ?

that sort of thing.

I'm looking at a Greenhouse data logger with a couple dozen remote
sensors.

Multi-channel ADC.
RTC
EEPROM

The ADC's will most likely be SPI as they are more common and carried
by Digi-Key.

RTC is a toss-up. can be either

ditto for the EEPROM

I am not looking for the ultimate, just the general ideas of what
people prefer.

Dave



The I2C parts tend to have more memory, and they
tend to have 3 address bits on each chip which
you can hardwire so it's easy to have 8 chips
on a 'bus'.

I find the SPI easier to interface in software,
but I like the I2C hardware better.

--- In , "Dave Mucha" <davemucha@j...> wrote:
> Hi All, > I've been discussing the different serial options and it seems that
> most chips are available in SPI or I2C.
>
> As a group discussion, can anyone offer what they use, and why they
> chose that ?
>
> It seems the the 3 wire is more common on chips like ADC's. But
> memory seems divided pretty well.
>
> Thanks in Advance.
>
> Dave




> I'm looking at a Greenhouse data logger with a couple dozen remote
> sensors.
> Multi-channel ADC.
> RTC
> EEPROM
> The ADC's will most likely be SPI as they are more common and carried
> by Digi-Key.
> RTC is a toss-up. can be either
> ditto for the EEPROM
> I am not looking for the ultimate, just the general ideas of what
> people prefer.

OK then... I prefer having as much as possible functionality inside of MCU.
That's why I try first to find MCU that is capable of handling most of the
things that I need. Only when some functionality is not available on MCU I
try to find other solution, preferably with serial interface. SPI or I2C -
doesn't really matter although it depends on application requirements as I
mentioned before.

Multi-channel ADC exists on PIC MCUs. RTC and EEPROM, too. Also, using
internal FLASH for data logging is another great idea if you have less than
100,000 erase/write cycles, which is possible if logging is done not so
frequently. Also, there are techniques for enhancing FLASH memory endurance.

What I'm trying to say is that you might integrate all of the functionality
in one of PIC18F6720 MCUs (or similar). They have low power 32.768kHz Timer1
used for RTC, 12 channel 10bit ADC and a lot of FLASH memory for data
storage (more than many serial EEPROMs). If power consumption is important
then you can use LF device. But, is this appropriate for your application?

Regards,
Igor



--- In , "Igor Janjatovic" <kodrat@p...> wrote:
> > I'm looking at a Greenhouse data logger with a couple dozen remote
> > sensors.
> > Multi-channel ADC.
> > RTC
> > EEPROM
> > The ADC's will most likely be SPI as they are more common and
carried
> > by Digi-Key.
> > RTC is a toss-up. can be either
> > ditto for the EEPROM
> > I am not looking for the ultimate, just the general ideas of what
> > people prefer.
>
> OK then... I prefer having as much as possible functionality inside
of MCU.
> That's why I try first to find MCU that is capable of handling most
of the
> things that I need. Only when some functionality is not available
on MCU I
> try to find other solution, preferably with serial interface. SPI
or I2C -
> doesn't really matter although it depends on application
requirements as I
> mentioned before.
>
> Multi-channel ADC exists on PIC MCUs. RTC and EEPROM, too. Also,
using
> internal FLASH for data logging is another great idea if you have
less than
> 100,000 erase/write cycles, which is possible if logging is done
not so
> frequently. Also, there are techniques for enhancing FLASH memory
endurance.
>
> What I'm trying to say is that you might integrate all of the
functionality
> in one of PIC18F6720 MCUs (or similar). They have low power
32.768kHz Timer1
> used for RTC, 12 channel 10bit ADC and a lot of FLASH memory for
data
> storage (more than many serial EEPROMs). If power consumption is
important
> then you can use LF device. But, is this appropriate for your
application?
>
> Regards,
> Igor


I think I've fallen into the incremental upgrade trap.

Started with a 16F873/876 and then added a RTC, then added a 12bit
ADC, then added memory for storage.... you get the idea. Instead of
starting from scratch, it is more incremental, just exapnding on the
origional.

The 12bit ADC is a minimum for me, and a bare minimum at best.

Now that I'm looking more at a clean sheet, I figured see what other
users have to say. I'm looking more at what you like and what you
didn't. Maybe why you chose one or the other.

I'm not looking for answers but more of peoples observations.

Dave



On Tue, 27 Apr 2004, Dave Mucha wrote:

> I'm not looking for answers but more of peoples observations.

Comparing the PIC pin numbers used for i2c and spi, sometimes can be the
same two (using a modified SPI). Thinking at the firmware, my impression
is that SPI and I2C have the same dificulty in implementation. Thinking at
addressing mode, i2C looks just a little better than SPI.
But the truth is that should be no discussion without knowing the project
full specification. Using both i2c and SPI in the same project is also
possible. Not always the cost is essential but also the availability. best regards,
vasile



> Now that I'm looking more at a clean sheet, I figured see what other
> users have to say. I'm looking more at what you like and what you
> didn't. Maybe why you chose one or the other.
>
> I'm not looking for answers but more of peoples observations.

Lowest cost 12bit ADC that I managed to find is LTC1860/LTC1861 from Linear
Technology ($2.3/$2.8). Low power version is LTC1860L. It is SPI type of ADC
with one (1860) or two channels (1861). Instead of looking for multi-channel
ADC I prefer using low cost single channel ADC and 4051 analog
multiplexer/demultiplexer controlled by PIC. It takes one 4051 for 8 analog
channels. Also, I use this trick when I want to expand number of ADC
channels on PIC MCU. This is just one of mine observations :) I hope it
helps...

Regards,
Igor