cancel
Showing results for 
Search instead for 
Did you mean: 

SPI chip select pin

parisa
Senior

Hello,

I need to connect more than 2 MCUs with SPI connection(1 Master, 2Slaves). Here is my Hardware connections :

MISO1->MOSI2 && MOSI3

MOSI1->MISO2 && MISO3

SCK1->SCK2 && SCK3

NSS1->NSS2 && NSS3

But I don't know how I can select each slave with master (MCU1). Is there any SPI chip select available in the MCU or it i desired?

1 ACCEPTED SOLUTION

Accepted Solutions
S.Ma
Principal

If you have 2 slaves and it's a multi-drop bus, use 2 GPIOs on the master side and connect each one of them to the NSS of each slave.

Then you can use the HW NSS SPI function on slave side to disconnect MISO when NSS is high (unselected).

In my projects, I used a different scheme to have up to 12 SPI slaves with 6 pins in multidrop mode. This is another story, although all works fine without NSS HW setup, I use NSS as EXTI interrupt to disable MISO pin and it's working fine, while having the HW NSS option as fallback.

View solution in original post

5 REPLIES 5
TDK
Guru

Take out the NSS line. The hardware NSS signal is not useful.

Instead, hook up two CS lines as general GPIO pins from the master to slave. One line per slave. Hold those high by default and select a slave by pulling that line low during communication.

If you feel a post has answered your question, please click "Accept as Solution".
S.Ma
Principal

If you have only 1 master and 1 slave, it's point to point, so yes, you don't need to bother with NSS on the slave side to put tristate MISO by NSS high level.

parisa
Senior

I really appreciate your explanation.

In the software, how can I implement this chip select pin? it means if the line is high I should ignore the incoming packets or there is another approach to implement in SPI software and it configures the software the CS pins.

Thank you for you comment.

In the 1master and 2 clients configuration should I use NSS pin?

S.Ma
Principal

If you have 2 slaves and it's a multi-drop bus, use 2 GPIOs on the master side and connect each one of them to the NSS of each slave.

Then you can use the HW NSS SPI function on slave side to disconnect MISO when NSS is high (unselected).

In my projects, I used a different scheme to have up to 12 SPI slaves with 6 pins in multidrop mode. This is another story, although all works fine without NSS HW setup, I use NSS as EXTI interrupt to disable MISO pin and it's working fine, while having the HW NSS option as fallback.