simple SPI hookup question (hardware)

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello:

I am using an ATMEGA48 device with several SPI parts. I have hooked up single devices to SPI in the past, just blindly going about it & working well.
Now, however, I need to hook up 3 different devices---can SPI handle this? I'm not sure how each of the different devices is "addressed"---so that writing to one doeesn't cause a write to the other. All of the various notes I see refer only to hooking up one device--which is all i needed in the past.

Looking at the datasheets seems to indicate that each device needs a separate I/O select line (Slave select) from the cpu---this seems wasteful if a lot of SPI devices (say 7) were being used.---I was under the impression that only 4 lines would be needed regardless of the peripheral total.

Any tips or comments appreciated!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You've got it right--the normal SPI addressing method is chip selects. And it does add up to several more pins.

You are, of course, welcome to use any of the inter-chip bus technologies (e.g., "addressable" I2C). Each has its plusses or there wouldn't be a variety of slave chips available.

For a long chain of devices, consider using a decoder chip. Up to 4 devices can be addresses/selected with 2 I/O lines, and up to 8 with 3 I/O lines.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you need to use multi SPI devices you could mux the chip select line with this divice
[url]http://www.analog.com/en/prod/0,... [/url]
ADG738 from analog devices, the datasheet has an exampe of this

Troy

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can have several 'output devices' like dacs with separate chip selects and the MOSI goes to all of them. But when you have more than one spi 'input device' like an a/d chip, make sure the MISO on that device goes hi impedance when you remove chip select, or else you need to use an ls126 to select each miso from each chip one at a time.

Imagecraft compiler user