3.5" display using ILI9488 will not work with XPT2048_Touchscreen

Status
Not open for further replies.

KrisKasprzak

Well-known member
All,

I just bought a large 3.5" display that works fine with the ILI9488_t3 library (using my Teensy 3.2). I'm trying to get it working with the XPT2048_Touchscreen library, the display works but not touch capability. I'm using shared SPI pins. Here's what works and doesn't work

Display
https://www.amazon.com/gp/product/B07W84SX8K/ref=ppx_yo_dt_b_asin_title_o09_s00?ie=UTF8&psc=1

I realize the display drive listed on the web page says ILI9486--but trying that driver did not work with shared pins with the XPT2048

2.8" TFT with ILI9488 + XPT2048_Touchscreen using shared SPI bus works fine
3.5" TFT with ILI9488 + XPT2048_Touchscreen using shared SPI bus does not work
3.5" TFT with ILI9488 + UTourch using separate SPI pins for the UTouch library works fine

I really want to get this 3.5" TFT with ILI9488 + XPT2048_Touchscreen using shared SPI bus working as I need to minimize pin usage.

Anyone have experience with this setup? Here's my code

Thanks in advance

Code:
#include <SPI.h>
#include "ILI9488_t3.h"
#include <XPT2046_Touchscreen.h>

#define CS_PIN  5
#define TIRQ_PIN  8
#define TFT_DC  2
#define TFT_CS  9

XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN);
ILI9488_t3 tft = ILI9488_t3(&SPI, TFT_CS, TFT_DC, 7);

void setup() {

  Serial.begin(38400);

  SPI.begin();

  pinMode(TIRQ_PIN, INPUT);
  pinMode(CS_PIN, OUTPUT);
  pinMode(TFT_DC, INPUT);
  pinMode(TFT_CS, INPUT);

  ts.begin();
  ts.setRotation(1);
  
  tft.begin();
  tft.setRotation( 1 );
  tft.fillScreen(ILI9488_BLACK);

  while (!Serial);

  tft.setTextColor(ILI9488_YELLOW);

  tft.setCursor(10, 100);
  tft.print("waiting for Serial Monitor");
  delay(1000);



}

void loop() {

  if (ts.tirqTouched()) {
    if (ts.touched()) {
      TS_Point p = ts.getPoint();

      Serial.print(p.x);
      Serial.print(", ");
      Serial.println(p.y);
    
      delay(30);
    }
  }
}
 
Problem might miso on display not tristated, can that be disconnected?

I got one like that and LCD midi active during touch makes it fall
 
I tried disconnecting my miso wire from the teensy to the display, still no touch capability on the 3.5". I tried adding pullups to MISO and MOSI for the touch no help.

Any further assistance greatly appreciated.

I have a cheap USB oscilloscope, but not sure what to even look at. If you can think of what I can measure, i'll let you know what my scope reads

Thanks in advance
 
While I can not be 100% sure that the display is the same as the one I have the odds are the same. Unfortunately I was never able to get the touch working with the display on the same SPI bus until I added a tri-state buffer chip on the MISO line with the 3.5inch display. Its one or the other if you don't use a buffer chip.

As @defragster pointed out PRJC's BETTER SPI DESIGN blog explains this as:
Most SPI chips will tri-state (effectively disconnect) their MISO pin when their chip select signal is high (inactive).
However, some chips do not have proper MISO tri-state behavior. Fortunately, checking MISO tri-state is easy, especially when prototyping on a breadboard. Just connect two 10K resistors to the MISO line, like this:
Information is available in the blog on how to check for this.
 
rats.....

My 2.8" TFT that works with the XPT2048_Touchscreen library has HR2046 written on the controller chip
My 3.5" TFT that does not work with the XPT2048_Touchscreen library has XPT2046 written on the controller chip

I tried pullups on both chip selects and resistors connected to MISO like in the blog

Still no luck.

Oddly the 3.5" TFT works with the UTouch libs (with its own SPI bus)
 
rats.....

My 2.8" TFT that works with the XPT2048_Touchscreen library has HR2046 written on the controller chip
My 3.5" TFT that does not work with the XPT2048_Touchscreen library has XPT2046 written on the controller chip

I tried pullups on both chip selects and resistors connected to MISO like in the blog

Still no luck.

Oddly the 3.5" TFT works with the UTouch libs (with its own SPI bus)

I had the same problem .. took me a day to figure out what was going on .was wondering if you got it resolved ... I fixed mine by removing the MISO connection that connects to the TFT ..
its all working now ... Something . to do with the miso line and tri-state...anyhow if you don't plan to download images off the display then this is a good solution ..
 
its all working now ... Something . to do with the miso line and tri-state...anyhow if you don't plan to download images off the display then this is a good solution ..
That's exactly it.

The ILI9488 needs a tri-state buffer on the MISO line to get touch working with the display. I tested it with a buffer chip installed and it worked without a problem.
 
That's exactly it.

The ILI9488 needs a tri-state buffer on the MISO line to get touch working with the display. I tested it with a buffer chip installed and it worked without a problem.

Can you please share what buffer chip did you install?
Thank you
 
good news is you got a buffer chip to work, bad news is that I tied a 74AHC1G125 and it did not work.

Yes please share the chip you used.
 
good news is you got a buffer chip to work, bad news is that I tied a 74AHC1G125 and it did not work.

Yes please share the chip you used.

Curious if you were able to get this to work? I have not played with the ILI9488 display in awhile.

However recently on a board for RA8875 or ...76 which has similar issue. I did put on a buffer chip (5 pin) which I believe is working. With the CE pin connected up to Not OE pin of the buffer.
And this is connected up to the MISO pin of the tft (not the MISO of the touch).

I am not sure how useful information that is being returned on the MISO of the display, so another option might be to not connect the tft miso pin...

I was just looking around after starting to play with webserver stuff and saw your nice video for the ESP32.
 
good news is you got a buffer chip to work, bad news is that I tied a 74AHC1G125 and it did not work.

Yes please share the chip you used.

Not sure how I missed this one Kris, my apologies. But if still interested the buffer chip I used was actually the same one as you are using: https://www.pjrc.com/better-spi-bus-design-in-3-steps/


Used this circuit on shield breakout board
Capture.PNG
 
Thanks, interesting wiring of MISO on the display. I see you have the displays MISO on the buffer output. I would expect the output of the display (miso) to be the input to the buffer or am I missing something?
 
Interesting, I'm reordering some more buffers and will give this a second try.

Hi Kris - just needed to verify that the hook up in that schematic I posted worked (been a while) so I hooked up my breakout board with just the buffer chip between the T4.0 and the ILI9488:
IMG-0616.jpg
Code:
, x = 1630, y = 2416
, x = 1625, y = 2427
, x = 1647, y = 2382
, x = 1678, y = 2377
, x = 1661, y = 2428
, x = 1643, y = 2453
no touch
no touch
no touch
, x = 1300, y = 1348
, x = 960, y = 1720
, x = 928, y = 1861
, x = 940, y = 1971
, x = 921, y = 2034
, x = 930, y = 2027

So looks like it works as long as you get all the jumper wires right - which I didn't on the first try :)

Heres the sketch I used:
Code:
#include <ILI9488_t3.h>
#include <font_Arial.h> // from ILI9488_t3
#include <XPT2046_Touchscreen.h>
#include <SPI.h>

#define CS_PIN  7
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10

ILI9488_t3 tft = ILI9488_t3(&SPI, TFT_CS, TFT_DC, TFT_RST);


XPT2046_Touchscreen ts(CS_PIN);
#define TIRQ_PIN  14
//XPT2046_Touchscreen ts(CS_PIN);  // Param 2 - NULL - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, 255);  // Param 2 - 255 - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN);  // Param 2 - Touch IRQ Pin - interrupt enabled polling


void setup() {
  Serial.begin(38400);
  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9488_BLACK);
  ts.begin();
  ts.setRotation(1);
  while (!Serial && (millis() <= 1000));
}

boolean wastouched = true;

void loop() {
  boolean istouched = ts.touched();
  if (istouched) {
    TS_Point p = ts.getPoint();
    if (!wastouched) {
      tft.fillScreen(ILI9488_BLACK);
      tft.setTextColor(ILI9488_YELLOW);
      tft.setFont(Arial_60);
      tft.setCursor(60, 80);
      tft.print("Touch");
    }
    tft.fillRect(100, 150, 140, 60, ILI9488_BLACK);
    tft.setTextColor(ILI9488_GREEN);
    tft.setFont(Arial_24);
    tft.setCursor(100, 150);
    tft.print("X = ");
    tft.print(p.x);
    tft.setCursor(100, 180);
    tft.print("Y = ");
    tft.print(p.y);
    Serial.print(", x = ");
    Serial.print(p.x);
    Serial.print(", y = ");
    Serial.println(p.y);
  } else {
    if (wastouched) {
      tft.fillScreen(ILI9488_BLACK);
      tft.setTextColor(ILI9488_RED);
      tft.setFont(Arial_48);
      tft.setCursor(120, 50);
      tft.print("No");
      tft.setCursor(80, 120);
      tft.print("Touch");
    }
    Serial.println("no touch");
  }
  wastouched = istouched;
  delay(100);
}
 
Status
Not open for further replies.
Back
Top