How can I interface two slaves using the SPI on the microcontroller, where microcontroller is acting as the Master ?
Hi,
You will need to drive the CS signal for each slave device to enable/disable it.
If the slaves are well-behaved devices, this will work fine. The slave select line must be unique for each slave, but the data and clock lines are a shared bus. I have sucessfully used multiple devices of the same type (two DS1722 temp sensors or 2 MCP3208 8 channel ADCs).
Some devices are not well behaved. An SPI device is supposed to put its data out (MISO) pin in a high impedance state when it is not selected so that another slave can drive the line. Some devices do not do this. (I want to say that the Wiznet ethernet chip is guilty, or it could be the Vinculum; some device I have worked with in the past, anyway.) Some Maxim device (an IO expander, maybe) also does not behave correctly, ostensibly to allow multiple devices to be daisy-chained.
Anyway, the short answer is yes but there are exceptions.
-j
Hi,
here is a link to a page that provides some basic knowledge about SPI in general, with an extra chapter on driving more than one device from a master:
http://www.mct.net/faq/spi.html
Eberhard