Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TFT_eSPI_ESP32_C6.c and TFT_eSPI_ESP32_C6.h #3399

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Cincinnatu
Copy link

I added TFT_eSPI_ESP32_C6.c and TFT_eSPI_ESP32_C6.h to fix the ESP32C6 compilation error.
When using the TFT_eSPI library on Arduino, I found that using TFT_eSPI_ESP32 did not compile correctly. After several attempts and modifications, I finally chose to add the files TFT_eSPI_ESP32_C6.c and TFT_eSPI_ESP32_C6.h to resolve the compilation issues

@OscarTofa
Copy link

I am trying the new files you made. at the compilation level there are no errors but when I go to load the esp32c6 program it crashes and restarts.
11:50:40.866 -> [ 817][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x4200d956
11:50:40.866 -> [ 817][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 14 successfully set to type GPIO (1) with bus 0xf
11:50:40.866 -> [ 818][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 14 successfully set to type SPI_MASTER_MOSI (36) wiGuru Meditation Error: Core 0 panic'ed (Store access fault). Exception was unhandled.
11:50:41.218 ->
11:50:41.218 -> Core 0 register dump:

Copy link

@crmbz0r crmbz0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have marked the changes that I made for myself which seem to have made it work. I've compiled probably 50 times successfully already with these files and the small changes made.
Also, here is a setup that finally worked with the pins and no errors or faulty connections to a ILI9488 TFT LCD shield via parallel.
When running the test on the pins, I had to put the GPIO printed number into the user setup file (where I also connected the cables to) and the actual pin number into the test code I ran to check the connections (you will see what I mean in the comments behind the pins).
Not sure if that is "normal", I always thought that the written GPIO names are used but apparently not.. well whatever, I am not that long into ESP32 coding stuff, but at least I can compile my stuff with the ILI9488 now :)

#include <driver/gpio.h> 
#define USER_SETUP_ID 70

#define ILI9488_DRIVER    
#define TFT_PARALLEL_8_BIT

#define TFT_CS   23     //   testPin(21, "TFT_CS");  // GPIO23
#define TFT_DC   19     //   testPin(17, "TFT_DC");  // GPIO19
#define TFT_RST   1     //   testPin(9, "TFT_RST");  // GPIO1
#define TFT_WR   11     //   testPin(12, "TFT_WR");  // GPIO11
#define TFT_RD    0     //   testPin(8, "TFT_RD");  // GPIO0

#define TFT_D0    4     //   testPin(4, "TFT_D0");  // GPIO4
#define TFT_D1    5     //   testPin(5, "TFT_D1");  // GPIO5
#define TFT_D2   12     //   testPin(13, "TFT_D2");  // GPIO12
#define TFT_D3   13     //   testPin(14, "TFT_D3");  // GPIO23
#define TFT_D4   18     //   testPin(16, "TFT_D4");  // GPIO18
#define TFT_D5    6     //   testPin(6, "TFT_D5");  // GPIO6
#define TFT_D6    7     //   testPin(7, "TFT_D6");   // GPIO7
#define TFT_D7   22     //   testPin(20, "TFT_D7");   // GPIO22

#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_FONT6
#define LOAD_FONT7
#define LOAD_FONT8  
#define LOAD_GFXFF  

#define SMOOTH_FONT

// #define SPI_FREQUENCY   1000000
// #define SPI_FREQUENCY   5000000
// #define SPI_FREQUENCY  10000000
//#define SPI_FREQUENCY  20000000
#define SPI_FREQUENCY  27000000

#define SPI_READ_FREQUENCY  20000000

// Select the SPI port to use, ESP32 has 2 options
#if !defined (TFT_PARALLEL_8_BIT)
#ifdef CONFIG_IDF_TARGET_ESP32
#ifdef USE_HSPI_PORT
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifdef USE_HSPI_PORT
#ifdef USE_FSPI_PORT

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESP32-C6 apparently only uses FSPI so I just replaced every HSPI and VSPI with FSPI. Not sure if necessary, but I haven't noticed any negative effects by doing that and I've been able to compile multiple different (small) test firmwares.

#if !defined (TFT_PARALLEL_8_BIT)
#ifdef CONFIG_IDF_TARGET_ESP32
#ifdef USE_HSPI_PORT
SPIClass spi = SPIClass(HSPI);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SPIClass spi = SPIClass(HSPI);
SPIClass spi = SPIClass(FSPI);

#elif defined(USE_FSPI_PORT)
SPIClass spi = SPIClass(FSPI);
#else // use default VSPI port
SPIClass spi = SPIClass(VSPI);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SPIClass spi = SPIClass(VSPI);
SPIClass spi = SPIClass(FSPI);

SPIClass spi = SPIClass(VSPI);
#endif
#else
#ifdef USE_HSPI_PORT
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifdef USE_HSPI_PORT
#ifdef USE_FSPI_PORT

#endif
#else
#ifdef USE_HSPI_PORT
SPIClass spi = SPIClass(HSPI);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SPIClass spi = SPIClass(HSPI);
SPIClass spi = SPIClass(FSPI);

RD_L;
uint32_t reg; // Read all GPIO pins 0-31
reg = gpio_input_get(); // Read three times to allow for bus access time
reg = gpio_input_get();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reg = gpio_input_get();
for (int i = TFT_D0; i <= TFT_D7; i++) {

Processors/TFT_eSPI_ESP32_C6.c Outdated Show resolved Hide resolved
Processors/TFT_eSPI_ESP32_C6.h Outdated Show resolved Hide resolved
Processors/TFT_eSPI_ESP32_C6.h Outdated Show resolved Hide resolved
Processors/TFT_eSPI_ESP32_C6.h Outdated Show resolved Hide resolved
@AlanChatflix
Copy link

With the official Espressif ESP32-C6-DevKitC-1-N8 Development Board (Amazon) connected to a 2.8 TFT Display 240x320 (touch display) which works perfectly on MEGA Arduinos with ILI9341 DRIVER.

I tried your update on my code by:

Copying: TFT_eSPI_ESP32_C6.c
Copying: TFT_eSPI_ESP32_C6.h
Updating: TFT_eSPI.cpp
Updating: TFT_eSPI.h

But it still doesn't work at all.
First of all, this ESP32 has no VSPI, it's FSPI:

image

I get it to compile when I do:

#define USE_FSPI_PORT

But then it keeps crashing and rebooting with this error:

Guru Meditation Error: Core 0 panic'ed (Store access fault). Exception was unhandled.

I also tried with ILI9341_2_DRIVER, but the same happens.

Can you guys check this and see if there's any quick fix?

@AlanChatflix
Copy link

With the official Espressif ESP32-C6-DevKitC-1-N8 Development Board (Amazon) connected to a 2.8 TFT Display 240x320 (touch display) which works perfectly on MEGA Arduinos with ILI9341 DRIVER.

I tried your update on my code by:

Copying: TFT_eSPI_ESP32_C6.c

Copying: TFT_eSPI_ESP32_C6.h
Updating: TFT_eSPI.cpp
Updating: TFT_eSPI.h
But it still doesn't work at all. First of all, this ESP32 has no VSPI, it's FSPI:

image

I get it to compile when I do:

#define USE_FSPI_PORT

But then it keeps crashing and rebooting with this error:

Guru Meditation Error: Core 0 panic'ed (Store access fault). Exception was unhandled.

I also tried with ILI9341_2_DRIVER, but the same happens.

Can you guys check this and see if there's any quick fix?

@crmbz0r

Cincinnatu and others added 2 commits September 27, 2024 14:51
…ESP32S3, and ESP32C6 cannot use the TFT library in ESP3.0 version.
@emblink
Copy link

emblink commented Oct 9, 2024

Hi, I am trying to use TFT_eSPI with the XIAO ESP32-C6. I pulled PR #3399, which resolves the compilation issues for this MCU in Arduino IDE. However, I still cannot get my ST7789 240x240 display working via SPI. The wiring and pinout are correct, as it functions with other libraries. Is there anything else needed to make this work on the ESP32-C6? Any advice or insights would be greatly appreciated!

@DanielBrkr
Copy link

DanielBrkr commented Oct 9, 2024

@emblink I got it working yesterday with a pretty similar setup (same display controller), I think you need to enable #define TFT_SDA_READ and #define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW) in the User_Setup.h file.
Let me know if that works, happy to help if it doesn't

@emblink
Copy link

emblink commented Oct 9, 2024

Hi @DanielBrkr,
Thank you so much! #define TFT_SDA_READ resolved the issue.
It’s a bit tricky, as it's not directly mentioned in #include <User_Setups/Setup24_ST7789.h>. I didn’t wire the MISO line to the display, and since my setup worked with Adafruit_ST7789.h, I didn’t expect a "read" operation to be needed here. I also commented out User_Setup.h and missed the TFT_SDA_READ reference there—my mistake!

Thanks again for your help!

@Cincinnatu
Copy link
Author

This is the final version modified based on the reference.:https://github.com/Cincinnatu/TFT_eSPI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants