Psoc 4, SCB SPI more than 4 slaves on the same bus

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ThBi_3905606
Level 2
Level 2
10 replies posted 10 questions asked 10 sign-ins

I need to connect more than 4 slaves devices to my master SPI Psoc4.

I know that for UDB SPI there is some information on datasheet about digital demultiplexer and control register

but I want to know how do that with a SCB SPI component

My issue so far, I do not know how connect the control reg and the demultiplexer (in the top design, i can only connect into one select input of the demux)

Maybe somebody can have some code

thanks

0 Likes
1 Solution

Hi @Thomas_Billiou

Sorry, I did not read the question correctly. The SPI hardware supports only 4 SS lines. If you want to use more than 4 slaves, you can go for software controlled SS lines.

SPI_SS0_Write(0); //Select SS0

Perform transaction

SPI_SS0_Write(1); //De-select SS0

SPI_SS1_Write(0); //Select SS1

Perform transaction

SPI_SS1_Write(1); //De-select SS1

SPI_SS2_Write(0); //Select SS2

Perform transaction

SPI_SS2_Write(1); //De-select SS2

etc..

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
3 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi ThBi_3905606​,

1. Set no of slave selects to 4 in SPI component

pastedImage_0.png

2. Connect them to appropriate pins in the pins tabs of DWR.

pastedImage_1.png

3. All the 4 slaves will share the same MISO, MOSI and SCLK. Each slave will have separate SS line from master.

4. Use the API  SPI_SpiSetActiveSlaveSelect(uint32 slaveSelect) to select which line is asserted for the transfer you are going to make. See component datasheet for details. For example

SCB_SpiSetActiveSlaveSelect(0); //Select SS0

Perform SPI transaction to Slave 0

SCB_SpiSetActiveSlaveSelect(0); //Select SS1

Perform SPI transaction to Slave 1
etc..

Let us know if this helps.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes

Hi Bragadeesh,

thank for your answer, but I need to connect more than 4 slaves. I need to connect 5, 6 or 8 slaves

0 Likes

Hi @Thomas_Billiou

Sorry, I did not read the question correctly. The SPI hardware supports only 4 SS lines. If you want to use more than 4 slaves, you can go for software controlled SS lines.

SPI_SS0_Write(0); //Select SS0

Perform transaction

SPI_SS0_Write(1); //De-select SS0

SPI_SS1_Write(0); //Select SS1

Perform transaction

SPI_SS1_Write(1); //De-select SS1

SPI_SS2_Write(0); //Select SS2

Perform transaction

SPI_SS2_Write(1); //De-select SS2

etc..

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes