I2S conflict with touchscreen?

Status
Not open for further replies.

Dionysus

Active member
In November of 2018 there was a post about an SPI conflict between the audio sheild and the touchscreen. Has anything changed since then? It sounds like folks are getting touchscreens to work with the audio board, right?

I'm posting my modified TouchTest code—I just added in the Audio library and a I2S object. When I comment those lines out, it works fine. With them in there, it prints a bunch of garbage data and then freezes up. Hopefully I've just missed an obvious thing? Thanks!

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

#include <Audio.h>
AudioOutputI2S           i2s1;           //xy=994,343
#define CS_PIN  14
// MOSI=11, MISO=12, SCK=13

//XPT2046_Touchscreen ts(CS_PIN);
#define TIRQ_PIN  1
//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);
  ts.begin();
  ts.setRotation(1);
  while (!Serial && (millis() <= 1000));
}

void loop() {
  if (ts.tirqTouched()) {
    TS_Point p = ts.getPoint();
    Serial.print("Pressure = ");
    Serial.print(p.z);
    Serial.print(", x = ");
    Serial.print(p.x);
    Serial.print(", y = ");
    Serial.print(p.y);
    delay(30);
    Serial.println();
  }
}
 
ARgh, I can't believe I forgot to give my hardware specs! This is a teensy 4.0, with audio sheild rev d and the PJRC touchscreen.

And I finally got everything to work, somehow. I tried moving the Touschscreen CS pin to 15 from 14, because the SD card is using 14 for SCK, but the display stopped working for some reason so I moved it back.

As far as I can tell, the magic thing that I did was to add

Code:
#define TS_CS       8
XPT2046_Touchscreen ts(TS_CS, TIRQ_PIN);  // Param 2 - Touch IRQ Pin - interrupt enabled polling
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);

So now that TFT display and the Touch interface are using different CS pins. That might have been incredibly obvious, but it wasn't to me! Anyway, for people in the future who come across this post, here is the wiring that I have for the Teensy 4.0, the Audio Shield Rev D, and the Touchscreen Display:

Touchscreen:
DC = 9
Display CS=14
Touch CS = 8
MOSI=11
Display CLK=13
Touch CLK=13
MISO=12
IRQ=1
T_DO =12
T_DIN=11


Audio / SD Card:
CS = 10
MOSI=7
SCLCK=14

Code:
#include <ILI9341_t3.h>
#include <font_Arial.h> // from ILI9341_t3
#include <XPT2046_Touchscreen.h>
#define TFT_DC      9
#define TFT_CS      14  // This is for the display screen, not the touch interface Or maybe both!?
#define TFT_RST    255  // 255 = unused, connect to 3.3V
#define TFT_MOSI    11
#define TFT_SCLK    13
#define TFT_MISO    12
#define TIRQ_PIN    1
#define TS_CS       8

XPT2046_Touchscreen ts(TS_CS, TIRQ_PIN);  // Param 2 - Touch IRQ Pin - interrupt enabled polling
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);


// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14
 
ARgh, I can't believe I forgot to give my hardware specs! This is a teensy 4.0, with audio sheild rev d and the PJRC touchscreen.

And I finally got everything to work, somehow. I tried moving the Touschscreen CS pin to 15 from 14, because the SD card is using 14 for SCK, but the display stopped working for some reason so I moved it back.

As far as I can tell, the magic thing that I did was to add

Code:
// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14

Those are the Teensy 3.x versions using the Audio Shield revisions A-C. For Revision D on the Teensy 4.0 (and forthcoming 4.1), you want:
Code:
// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  11
#define SDCARD_SCK_PIN   13
 
Ugh, you're totally right. Which explains why I wasn't worried about a conflict on 14 when I initially moved that pin. But it did work with those incorrect pin assignments! Either that, or I've gone completely mad, which is more likely because I can't see any reason why it would have. Especially since the larger program was able to read the SD card...

I changed the pin assignments to 10, 11, and 13, and now it still works, so that's good. It's messed up in other ways, but I don't know that they're connected. Thank you for pointing that out!
 
Status
Not open for further replies.
Back
Top