Loading...
Pages: [1]   Go Down
Author Topic: SPI slave select + two shields  (Read 502 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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: http://arduino.cc/forum/index.php?topic=134581.0

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.
http://www.uctronics.com/download/arduinolcd/3inch2_Arduino_LCD_Shield_UG.pdf

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.
http://maniacbug.wordpress.com/2011/11/02/getting-started-rf24/

The LCD display with the NRF work perfectly together, here is an example of my work:
https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-prn1/602233_341076379343329_2109883873_n.jpg

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!
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 269
Posts: 17032
Available for Design & Build services
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
http://www.crossroadsfencing.com/BobuinoRev17/
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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 72
Posts: 2500
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...)

Logged

No, I don't answer questions sent in private messages...

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 269
Posts: 17032
Available for Design & Build services
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17

Offline Offline
Full Member
***
Karma: 0
Posts: 190
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have to have rf24 and rf24network libraries installed.  You set pins when you create an instance of rf24
« Last Edit: March 05, 2013, 10:01:49 pm by ematson5897 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 190
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1]   Go Up
Print
 
Jump to: