1

Reposting this question asked by someone else a few years ago because it was unanswered and I am facing the same problem.

I want to use a touchscreen LCD (3.5" TFT) and a MPC3008 ADC at the same time to monitor data fast and continuously in my project. And I know the data interface of each three parts (LCD, touch, and MPC3008) is SPI.

Now here are my questions:

1) Is it possible to use all 3 devices at once?

2) If yes, should I use an auxiliary SPI to handle it? How would I do that?

3) If No, what's your suggestion?

4) What changes should I make to both code and configuration?

This issue is very important to me. Please Help.

Thanks a lot.

3.5-inch touch screen TFT LCD for raspberry pi

Above is the photo of LCD I have

Below is the MCP pin configuration I'm using.

MCP 3008 configuration

**

  • Yes you can use them at the same time. Using the auxiliary SPI is probably the simplest method. If you don't know how to do it and are apparently unwilling to learn I suggest you employ a professional to do the job for you. – joan May 15 at 12:03
0

Let me see. Your touch screen needs 2 chip selects. So it uses up Rpi's only two chip selects CS0, CS1.

There are a couple of ways to get around. See the post below for more details.

SPI AND CHIP SELECT PINS - planeta9999 2013-Jan-23

I actually tried all the things suggested in the above post, and they all work. I have also tried other things as briefly described below.

  1. "Create" more SPI channels by fiddling the 3V3 to 5V0 logical level converter such as TSX0104. I use 4 TSX0104 converters, each enabled by a Rpi GPIO pin. So by enabling one of the 4 TSX0104s, I can select one of the four SPI channels. Of course you can create more SPI channels by using more TSX004s. This is not soft ware bit banging, because the real Rpi SPI channel hardware is used. In other words, almost as fast as the original real Rpi SPI.

  2. Same as 1. above, but instead of using Rpi GPIO pins, use I2C MCP23017 IO port expander. MCP23017 has 16 GPIO pins. So you can select any one of 16 deMUX SPI channels. Of course you can use more MCP23017. I once tried 8 MCP23017s to select 16 x 8 = 128 devices, but it get unstable when you scale up more than 2 MCP23017s.

But there is one catch. In the above methods, you forget the Rpi chip selects (just disconnect them), and use you own chip selects. This works for all the SPI devices I work so far, except those like WaveShare touch LCD, which uses their own drivers, insisting to use Rpi's CS0, CS1.

Of course you can mess around WaveShare's driver software, but that is very difficult for newbies, and not linux version invariant.

Now for newbies, I usually recommend the following.

Forget the very old, low 10/12 bit resolution SPI MCP3x0y,

Use the new 16/24 bit I2C ADCs instead.

In the brave I2C new world, you have too many more devices to choose, and that is why the SPI guys are getting so jealous. And that is why I2C is getting so popular over SPI (so many more I2C modules, comparing with SPI).

So check out AdaFruit and SparkFun what new I2C ADCs they are recommending.

waqveshare touch ldc

WaveShare 3.5inch RPi LCD (A), 480x320 US$23.99

WaveShare 3.5inch RPi LCD Technical Notes

320 x 480, 8:5, 65536 colours, TFT, Backlight LED, 
SPI, Touch Screen Resistive, Controller XPT2046, 

PIN NO. SYMBOL  DESCRIPTION
11  TP_IRQ  Touch Panel interrupt, touch detect low
18  LCD_RS  Instruction/Data Register selection
22  RST Reset
19  LCD_SI / TP_SI  SPI data input of LCD/Touch Panel
21  TP_SO   SPI data output of Touch Panel
23  LCD_SCK / TP_SCK SPI clock of LCD/Touch Panel
24  LCD_CS  LCD chip selection, low active
26  TP_CS   Touch Panel chip selection, low active

Update 2019may15hkt1925

If you don't wish to replace SPI MCP3008 by another I2C ADC, you can consider use Rpi's second set of SPI. Again this is hard for newbies. Below is a picture for you to start exploring.

Second SPI

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.