SPI more than 4 slaves on the same SPI bus using Mux/Demux including SD card(EMfile)

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

cross mob
AbPa_4654881
Level 3
Level 3
10 replies posted 10 questions asked 10 likes given

Hi All,

I need to connect more than 4 slaves devices to my master SPI Psoc5LP. for that I am planning to use digital Demux/mux and control register something like the attached snapshot.

I have not much idea how to implement control reg and the Mux/Demux. Is there any example that is using Digital Multiplexer/Demultiplexer ?  please share any Example code. 

And other major issue I am facing is that  my one of the SPI component is SD card that is using EMFile Component library. so for EMfile component How I can play with EMfile Component SPI CS(chip select) pin to activate this SD card whenever is required ? because for EMfile all things are defined internally inside the Emfile component library.

Please suggest how I can Activate EMFILe SD card using Demux/mux whenever is required?Untitled.png

  Thanks

0 Likes
1 Solution
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

AbPa,

How many SPI Masters do you need for your project?

If only one Master, then you don't need the the Demux or Mux for the SPI_CLK, SPI_MOSI or SPI_MISO signals.

As indicated, the SPI Master component can directly control up to 4 Slave SSs with the API.   However since the SS signals are just GPIO,  you can create your own SS control manually in the code.

If more than one, then is it necessary to have all SPI slaves on the same SPI bus? 

If you need multiple Masters, then it might be best for each Master to have their own SPI bus to the respective Slaves to which they communicate. (Significantly simpler from a coding standpoint.)

As to the emFile system use of SPI ...


And other major issue I am facing is that  my one of the SPI component is SD card that is using EMFile Component library. so for EMfile component How I can play with EMfile Component SPI CS(chip select) pin to activate this SD card whenever is required ? because for EMfile all things are defined internally inside the Emfile component library.

Please suggest how I can Activate EMFILe SD card using Demux/mux whenever is required?

 

No matter how you answered my two questions above, I recommend the SD Card be on a separate SPI Master and SPI bus.

As you noted, the SPI Master is automatically allocated and controlled by the emFile library SW.  Because of this and the emFile SW uses it's own caching techniques, it is almost impossible to predict when the SPI is needed for the SD Card.   Trying to share this SPI with other Slaves would be a significant challenge.

Len

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

2 Replies
BiBi_1928986
Level 7
Level 7
First comment on blog 500 replies posted 250 replies posted

Hello.

When the SPI Master component is put into schematic, right-click on it and select Configure.  In bottom corner of newly opened window will have link to the SPI Master datasheet.  Look here to see how to control 4 SPI slave devices.  You can expand the examples to add more than 4 SPI slave devices.  Basically, it's only the Slave Select (SS) signal that needs to be controlled.  All other signals are tied together as shown in the examples.

So, only the SS signals need a demux (no mux).  The second example would work best for your application.  Your s/w sets the Control register to control the demux for the SS you want, then let SPI component control SS.

Good luck with your project.

Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

AbPa,

How many SPI Masters do you need for your project?

If only one Master, then you don't need the the Demux or Mux for the SPI_CLK, SPI_MOSI or SPI_MISO signals.

As indicated, the SPI Master component can directly control up to 4 Slave SSs with the API.   However since the SS signals are just GPIO,  you can create your own SS control manually in the code.

If more than one, then is it necessary to have all SPI slaves on the same SPI bus? 

If you need multiple Masters, then it might be best for each Master to have their own SPI bus to the respective Slaves to which they communicate. (Significantly simpler from a coding standpoint.)

As to the emFile system use of SPI ...


And other major issue I am facing is that  my one of the SPI component is SD card that is using EMFile Component library. so for EMfile component How I can play with EMfile Component SPI CS(chip select) pin to activate this SD card whenever is required ? because for EMfile all things are defined internally inside the Emfile component library.

Please suggest how I can Activate EMFILe SD card using Demux/mux whenever is required?

 

No matter how you answered my two questions above, I recommend the SD Card be on a separate SPI Master and SPI bus.

As you noted, the SPI Master is automatically allocated and controlled by the emFile library SW.  Because of this and the emFile SW uses it's own caching techniques, it is almost impossible to predict when the SPI is needed for the SD Card.   Trying to share this SPI with other Slaves would be a significant challenge.

Len

Len
"Engineering is an Art. The Art of Compromise."