SPI slave select + two shields

Hello, it's nice to be a part of this forum

I have a certain question about usage of Slave Select in SPI

I am working with NRF24L01 and a 3.2" LCD TFT with SSD1289. After troubleshooting, i found out that i was actually really stupid, using SPI with Slave Select pin 10 for both devices and also that the NRF device was interfering with the touch controller of the LCD. When i had both of the devices connected to the arduino, getX and getY always returned their max values. When i disconnected the NRF module, getX and getY worked perfectly. So i understood that i must use the SS pins to activate/deactivate each module so that every time only one of two is working while the other is "off".

With Arduino Uno, the LCD display uses pins A0-A6, touch uses SPI pins 10-13 and pins 1-7 are data buses, while pin 9 is SS for the TF card on the display. Here is a topic with basic code for the TFT LCD i'm using, if there is anything unclear: Arduino Forum

Both modules use SS pin 10. The LCD uses pin 9 as SS for the TF card. On the documentation of the LCD, there is no info about pin 8, so i'm thinking of using it as SS pin for the NRF module.

Instead of changing my custom shield for the NRF, i tried using SPI code to deactivate the display touch by changing the output of pin 10 from LOW to HIGH and see what happens (while having disconnected the NRF module of course).

If you take a look at the code in the topic i linked above, you can see that, while the LCD uses the SPI pins, it actually does not need inclusion of SPI headers and commands in the code. I understand that the touch controller is using the SPI bus, but when i try to add usage of SPI (including SPI.h, and adding SPI.begin() to my code), the touch stops working. What should i do so that i can use the SPI buses correctly with both the TFT and the NRF?

Here is a PDF with some useful information about the TFT shield for Arduino Uno, on page 4 are the pin definitions.

And here is an example of how i used the NRF module. I'm using the connections but not the MIRF library, i'm using the NRF network library.

The LCD display with the NRF work perfectly together, here is an example of my work:

The only problem is that i can't get touch and nrf to work together without one interfering with the other.

Thanks in advance, i hope i was very clear with my questions!

Sounds like you're out of pins if you have 2 devices using pin 10, and have a third, yet only have pin 8 free.
Maybe move up to a processor with some more pins, like ATmega1284P.

What's your custom shield like?
I offer an Uno compatible board that runs from '1284P, with 10 more IO pins.
bare board $6, can put one together for ~$20 depending on what you can scrounge from your parts bin and what you need to buy.

Sounds like you're out of pins if you have 2 devices using pin 10, and have a third, yet only have pin 8 free.

One pin is enough. Just hack one of the shields to use pin 8 (cut track, rewire...)

I have attached images of my shield.

I will use pin8 as SS for the NRF24L01, but i’m still wondering why the TFT LCD does not require the use of the SPI libraries and headers since it uses the serial interface.

Another problem is that in the RF24 Network library i can’t find where the SS pin is defined, so i can change it from 10 to 8.

"Note: Touch screen controller and TF card reader share the same hardware SPI port
(Pin11,Pin12,Pin13), they are activated by different chip select signals(Touch screen use Pin10,
while TF reader use Pin9)."
Maybe not using the SPI library, but accessing the hardware from lower level software. Atmel specs show both assembly language and C language examples for a lot of the hardware, so more than 1 way exists to skin that cat.
I haven't looked at the code available on github, must be a command or line there somewhere that allows different SS pins.

You have to have rf24 and rf24network libraries installed. You set pins when you create an instance of rf24

You have to have rf24 and rf24network libraries installed. You set pins when you create an instance of rf24

OK, i was wrong, you can actually set the CE and CSN pins in your code (RF24 and RF24 network libraries), i changed CSN to pin8. But now, when i use both shields, the TFT screen flickers when receiving an RF packet.

I can't understand if pin 8 plays some role in the functioning of the TFT.

This is a guess, but the display might need a constant stream of data, and the rf24 library is stopping that from occuring for a brief amount of time

Consider this:

what if i use the same pin (pin 10) for slave select for both the lcd and the nrf and i use a digital inverter on one of the two, so that when the one is working (high) the other is idle (low)?

Can that be possible?