A 786
A 786

Reputation: 557

How Multiple slave to single master SPI software slave management works

I am using STM32H7 family of microcontroller as SPI Master Transmit device which needs to talk to 4 SPI slave devices receive only which are also all STM32H7 MCU's. Both master and slave are configured for software slave management. The confusion is how slave will identify when master wants to talk to it or transmit data to it without using hardware NSS pin? How slave device will start receiving in this scenario and stop receiving when all data transmitted?

Upvotes: 1

Views: 5413

Answers (3)

Junseok Oh
Junseok Oh

Reputation: 11

It seems that the code shown below can manage the problem.

__HAL_SPI_ENABLE(&hspi1);
__HAL_SPI_DISABLE(&hspi1);

Upvotes: 0

Codo
Codo

Reputation: 78915

If you use software slave select (NSS), you must select and deselect the SPI interface by software.

Typically, you would setup an external interrupt on the pin used as NSS/CS and select/deselect the SPI interface when the interrupt is triggered.

On an STM32F1 chip, the SPI interface is selected/deselected by setting/clearing the SSI bit in the SPI_CR1 register. I assume it's very similar on a STM32H7 chip.

Update

I've just checked the STM32H7 and it's exactly the same.

Upvotes: 2

0___________
0___________

Reputation: 67820

It is very simple. Every slave has one pin called CS. You need to select this device by setting this pin just by using the GPIO. Then you can transmit or receive data. Remember that master has to supply clock even if it wants only to receive data.

Upvotes: 2

Related Questions