esp32_s3-n16R8 to a ili9488

Hello,

I’ve been 2 weeks in the project and i’ve been stil in the part to connect a esp32_s3-n16R8 to a ili9488 with a XPT2046 touchdriver.

The lib’s i’m using are;

   bodmer/TFT_eSPI@^2.5.1
   paulstoffregen/XPT2046_Touchscreen

and the pins for communication are:

#define TFT_MOSI 11
#define TFT_SCLK 12
#define TFT_CS 5
#define TFT_DC 4
#define TFT_RST -1
#define TFT_MISO 13
#define TOUCH_CS 15
#define TOUCH_IRQ 16

For the code i try to startup as simple as possible in platform.io

//user_setup
#define USER_SETUP_INFO "Custom Setup for ILI9488 on ESP32-S3 with T_IRQ on 14"
#define ILI9488_DRIVER
#define TFT_MOSI  11
#define TFT_SCLK  12
#define TFT_CS    5
#define TFT_DC    4
#define TFT_RST   -1
#define TFT_MISO  13
#define TOUCH_CS  15
#define TOUCH_IRQ 16
#define TFT_WIDTH  480
#define TFT_HEIGHT 320
#define SPI_FREQUENCY       20000000  // Reduced from 40000000 for stability
#define SPI_READ_FREQUENCY  0         // Disable reads if not supported
#define SPI_TOUCH_FREQUENCY 2500000
#define LOAD_GLCD
#define LOAD_FONT4
#define USER_SETUP_LOADED 1

//main

#include <Arduino.h>
#include <TFT_eSPI.h>
#include <XPT2046_Touchscreen.h>

TFT_eSPI tft = TFT_eSPI();
#define TOUCH_CS  15
#define TOUCH_IRQ 16
XPT2046_Touchscreen ts(TOUCH_CS, TOUCH_IRQ);

void setup() {
  Serial.begin(115200);
  delay(500);
  Serial.println("Starting setup...");

  Serial.println("Before tft.init()");
  tft.init();
  delay(100);  // Add delay after init as suggested
  Serial.println("After tft.init()");
  tft.setRotation(0);
  Serial.println("After setRotation()");
  tft.fillScreen(TFT_BLACK);
  Serial.println("After fillScreen()");
  tft.setTextColor(TFT_WHITE);
  tft.setTextSize(2);
  tft.setCursor(10, 10);
  tft.println("TFT OK");
  Serial.println("TFT OK printed");

  Serial.println("Before ts.begin()");
  ts.begin();
  Serial.println("After ts.begin()");
}

void loop() {
  if (ts.touched()) {
    TS_Point p = ts.getPoint();
    Serial.printf("Touch: x=%d y=%d\n", p.x, p.y);
    tft.fillCircle(p.x, p.y, 4, TFT_RED);
    delay(200);
  } else {
    delay(50);
  }
}
//platform.ini
[env:esp32-s3]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
lib_deps = 
    bodmer/TFT_eSPI@^2.5.0
    paulstoffregen/XPT2046_Touchscreen@^1.3
build_flags = 
    -DARDUINO_USB_CDC_ON_BOOT=1
    -Wl,-Map=output.map
    -DCONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240
    -DCONFIG_ESP_TASK_WDT_TIMEOUT=10

I comment evry driver out of the user_setup_select file.

The only thing after compiling is this in repeat:

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42022c26
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x42001d51 PS : 0x00060830 A0 : 0x82001f09 A1 : 0x3fcebbd0
A2 : 0x3fc95468 A3 : 0x00000001 A4 : 0x60004000 A5 : 0x00000010
A6 : 0x3fc9690c A7 : 0x00000000 A8 : 0x08000000 A9 : 0x3fcebba0
A10 : 0x3fc9690c A11 : 0x00000001 A12 : 0xffffffff A13 : 0x00000010
A14 : 0x00000000 A15 : 0x3fc93a08 SAR : 0x0000001c EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000010 LBEG : 0x42014000 LEND : 0x42014064 LCOUNT : 0x00000002

Backtrace: 0x42001d4e:0x3fcebbd0 0x42001f06:0x3fcebc00 0x420017b3:0x3fcebc30 0x4200384a:0x3fcebc50

ELF file SHA256: e99c734e52221776

The esp is this one:
Esp32

And the display is this one;
display

Is there a problem to let these 2 products work together?

Kind regards Bas

Before creating a complex sketch with displays etc, make sure a simply blink / hello world sketch works without problems.

For an ESP32-S3-N16R8 use these settings in your platformio.ini

Then try a simple hello world sketch:

#include <Arduino.h>

void setup() {
    Serial.begin(115200);
}

void loop() {
    Serial.println("Hello World");
    delay(1000);
}

Does it work without issues?

Ijust compile and after setting serial monitor in platform.io file it’s working without problems

Yeah we’ve already talked about that exact bug in

Thanks, this is indeed fix the display trouble. The display works now but the serial is saying --- Terminal on COM11 | 115200 8-N-1 --- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time --- More details at https://bit.ly/pio-monitor-filters --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3808,len:0x4bc load:0x403c9700,len:0xbd8 load:0x403cc700,len:0x2a0c entry 0x403c98d0 E (94) psram: PSRAM ID read error: 0x00ffffff, PSRAM chip not found or not s�ppStart TFT + Touch test [ 101][E][esp32-hal-spi.c:215] spiAttachMISO(): HSPI Does not have default pins on ESP32S3! No touch

The user_setup contains:

// ==== TFT_eSPI setup for ILI9488 on ESP32-S3 using VSPI (SPI3) ====

// Display driver
#define ILI9488_DRIVER

// TFT over VSPI (SPI3)
#define TFT_MOSI    35   // VSPI MOSI
#define TFT_MISO    -1   // Niet gebruikt door display
#define TFT_SCLK    36   // VSPI SCLK
#define TFT_CS      39   // VSPI CS
#define TFT_DC      38   // Aparte GPIO voor DC
#define TFT_RST     37   // Aparte GPIO voor reset
#define TFT_BL      -1   // Backlight (optioneel, bijvoorbeeld GPIO 21)

// Touch (XPT2046) - software SPI of shared SPI3
#define TOUCH_CS    10   // Aparte GPIO voor touch CS
//#define TOUCH_IRQ   41   // Touch IRQ (optioneel)
//#define TOUCH_MISO  32   // Software SPI of gedeeld met VSPI
//#define TOUCH_MOSI  35   // Gedeeld met TFT MOSI
//#define TOUCH_SCLK  36   // Gedeeld met TFT SCLK

// SPI instellingen
#define SPI_FREQUENCY       27000000
#define SPI_READ_FREQUENCY  16000000
#define SPI_TOUCH_FREQUENCY 2500000

#define SUPPORT_TRANSACTIONS
#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_GFXFF
#define SMOOTH_FONT


and the main:

#include <TFT_eSPI.h>  // Laadt automatisch jouw User_Setup.h
#include <SPI.h>

TFT_eSPI tft = TFT_eSPI();  // TFT object
uint16_t x, y;              // Touch-coördinaten

void setup() {
  Serial.begin(115200);
  Serial.println("Start TFT + Touch test");

  tft.init();
  tft.setRotation(1);  // Portrait = 0 of 1, afhankelijk van display

  tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_WHITE, TFT_BLACK);
  tft.setTextSize(2);
  tft.setCursor(20, 40);
  tft.println("ESP32-S3 ILI9488 OK!");

  delay(1500);
  tft.fillScreen(TFT_BLACK);
  tft.drawString("Raak scherm aan...", 60, 20, 2);
}

void loop() {
  uint16_t x, y;
  bool touched = tft.getTouch(&x, &y);

  if (touched) {
    Serial.printf("Touched at: %d, %d\n", x, y);
    tft.fillCircle(x, y, 5, TFT_GREEN);
  } else {
    Serial.println("No touch");
  }

  delay(500);
}

again thanks for the push in the right direction.

Mhm, if the module is a ESP32-S3-WROOM-1-N16R8, then it should have 8 MB of octal PSRAM. So you definitely need to select the right board or memory type in the platformio.ini for that to be recognized.

A configuration is actually provided by @sivar2311 at https://github.com/sivar2311/ESP32-S3-PlatformIO-Flash-and-PSRAM-configurations?tab=readme-ov-file#esp32-s3-wroom-11u-n16r8 as posted above. So do you have those critical

board_build.arduino.memory_type = qio_opi
board_build.flash_mode = qio
board_build.psram_type = opi
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = default_16MB.csv
board_build.extra_flags = 
  -DBOARD_HAS_PSRAM

in your platformio.ini?

the platformio file is now

[env:esp32-s3-devkitc-1]
platform = espressif32@6.6.0
board = esp32-s3-devkitc-1
framework = arduino
board_build.arduino.memory_type = qio_qspi
board_build.flash_mode = qio
board_build.psram_type = qspi
board_upload.flash_size = 16MB
board_build.partitions = default_16MB.csv
board_build.extra_flags = 
	-DBOARD_HAS_PSRAM
monitor_speed = 115200

build_type = debug
monitor_filters =
  esp32_exception_decoder

it gives warning

C:/Users/me/.platformio/packages/framework-arduinoespressif32@3.20014.231204/cores/esp32/esp32-hal-uart.c: In function 'uartSetPins':
C:/Users/me/.platformio/packages/framework-arduinoespressif32@3.20014.231204/cores/esp32/esp32-hal-uart.c:153:9: warning: 'return' with no value, in function returning non-void
         return;
         ^~~~~~
C:/Users/me/.platformio/packages/framework-arduinoespressif32@3.20014.231204/cores/esp32/esp32-hal-uart.c:149:6: note: declared here
 bool uartSetPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)

but compiles for the rest and gives a text on screen. Touch not working but screen is working.

when i change to:

[env:esp32-s3-devkitc-1]
platform = espressif32@6.6.0
board = esp32-s3-devkitc-1
framework = arduino
board_build.arduino.memory_type = qio_opi
board_build.flash_mode = qio
board_build.psram_type = opi
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = default_16MB.csv
board_build.extra_flags = 
monitor_speed = 115200

build_type = debug
monitor_filters =
  esp32_exception_decoder

i get the same warning during compile but i dont have any output on the screen and getting the folowing in serial:

— Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a80
entry 0x403c98d0
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x10 (RTCWDT_RTC_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a80
entry 0x403c98d0

That’s very weird. What Arduino IDE → Tools settings and Arduino core version does it work perfectly with in the Arduino IDE?

OPI should definitely be the right PSRAM type for the S3-N16R8.

But besides that, about

is I think caused by the “-1” (meaning “default pin”) here

so you might want to change that to

#define TFT_MISO    32   // Niet gebruikt door display

and hope that the touch code then uses the same initialized SPI object (MISO, MOSI, SCLK) with just the newly set CS.

ok, now i’m disconnect the display from the esp and getting

--- Terminal on COM11 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
No touch
No touch
No touch
No touch
No touch

with this platformcode

`[env:esp32-s3-devkitc-1]
platform = espressif32@6.6.0
board = esp32-s3-devkitc-1
framework = arduino
board_build.arduino.memory_type = qio_opi
board_build.flash_mode = qio
board_build.psram_type = opi
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = default_16MB.csv
board_build.extra_flags = 
monitor_speed = 115200
build_type = debug
monitor_filters =
  esp32_exception_decoder
`

it look likes its something in the pins.

// TFT over VSPI (SPI3)
#define TFT_MOSI    35   // VSPI MOSI
#define TFT_MISO    40   // Niet gebruikt door display
#define TFT_SCLK    36   // VSPI SCLK
#define TFT_CS      39   // VSPI CS
#define TFT_DC      38   // Aparte GPIO voor DC
#define TFT_RST     37   // Aparte GPIO voor reset
#define TFT_BL      -1   // Backlight (optioneel, bijvoorbeeld GPIO 21)

// Touch (XPT2046) - software SPI of shared SPI3
#define TOUCH_CS    10   // Aparte GPIO voor touch CS