NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Multiple slaves on SPI connection

October 17, 2011
by claesz
claesz's Avatar

Hi again guys. Need some advice than I am sure is basic knowledge but perhaps you can point me in the right direction.

How would I go about connecting to multiple devices through SPI? All SPI communication defaults to PB2-5 on the 328p. Could I use another port, like any PC port, for slave selection, or would I time communication so that I first communicate with S1, then S2 etc. I found some posts touching on this on this forum, but a lot of it went woosh over my head. Any practical examples or code sniplets would be greatly appreciated.

October 18, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi claesz,

You would need one pin to select every slave you want to listen to that particular byte you are about to send across. In fact when a chip is a master, the SS pin is treated just like a normal digital output pin.

Humberto

October 18, 2011
by claesz
claesz's Avatar

Hi Humberto,

Thanks for your reply. So even if the 328p has only one dedicated SS pin, I could use any digital output pin on the master for the slave select?

As I understand SPI it relies on synchronized communication between master and slave. Can you still use a shift register to hook up more than one slave or would that create timing problems on communication?

October 18, 2011
by claesz
claesz's Avatar

Actually I think I found that the answer is "yes" you can use any digital pin as SS pin. It seems to have been discussed here:

http://www.nerdkits.com/forum/thread/1551/

My apologies.

Post a Reply

Please log in to post a reply.

Did you know that you can control multiple LEDs from one microcontroller output? Learn more...