Muzahir Hussain
Muzahir Hussain

Reputation: 1033

SPI configuation as master

I need to configure SPI_1 as master in Nucleo STM32F103RB. Here's what I did so far (Keil uvision 4).

// Configuring GPIOs


// SPI_SCK
GPIOA_CRL |= 0x00A00000; //Alternate function push-pull

// SPI_MOSI
GPIOA_CRL |= 0xA0000000; //Alternate function push-pull

// SPI_MISO
GPIOA_CRL |= 0x04000000; //Input floating

However I need to set nSS for multiple slaves. How do I do that? Which GPIO pins should I use to connect nSS pins to multiple slaves.

Also how many maximum slaves can I attach?

Upvotes: 1

Views: 189

Answers (1)

0___________
0___________

Reputation: 67855

You can use any GPIO. Just configure them as outputs and manually set their state to choose the slave. There is no other way for the multiple CS lines.

Upvotes: 2

Related Questions