tft.getTouch is killing other spi devices #915
-
been debugging my setup for days and narrowed it down to tft.getTouch project is an internet radio, tft_espi with lvgl on top, ethernet module with w5500, mp3 module with vs1053 #include <SPI.h> // spi chip selects #define CS_MP3 4 // network #define VS1053_CS 4 TFT_eSPI tft = TFT_eSPI(); /* TFT instance */ // set fixed IP address for the ethernet connection // set a mac address for the ethernet interface void setup() { Serial.begin(115200); /* prepare for possible serial debug */ pinMode(CS_MP3, OUTPUT); digitalWrite(CS_MP3, HIGH); tft.init(); // reset ethernet chip delay(2500); delay(500); digitalWrite(ETHERNET_CS, HIGH); } void loop() { Serial.println(Ethernet.localIP()); digitalWrite(CS_MP3, HIGH); } |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
just to be clear, my setup works well without internet/mp3 setup, menus, touch etc, i designed the overall structure first a main splash screen and a few other screens, then added the radio functions and got stuck |
Beta Was this translation helpful? Give feedback.
-
user setup file // USER DEFINED SETTINGS // ################################################################################## // Define STM32 to invoke optimised processor support (only for STM32) // Defining the STM32 board allows the library to optimise the performance // STM32 8 bit parallel only: // Tell the library to use 8 bit parallel mode (otherwise SPI is assumed) // Display type - only define if RPi display // Only define one driver, the other ones must be commented out // Some displays support SPI reads via the MISO pin, other displays have a single // #define TFT_SDA_READ // This option is for ESP32 ONLY, tested with ST7789 display only // For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display // #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue // For M5Stack ESP32 module with integrated ILI9341 display ONLY, remove // in line below // #define M5STACK // For ST7789, ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation // For ST7735 ONLY, define the type of display, originally this was based on the // #define ST7735_INITB // If colours are inverted (white shows as black) then uncomment one of the next // #define TFT_INVERSION_ON // ################################################################################## // If a backlight control signal is available then define the TFT_BL pin in Section 2 // #define TFT_BL 32 // LED back-light control pin // We must use hardware SPI, a minimum of 3 GPIO pins is needed. // ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP8266 SETUP ###### // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation //#define TFT_BL PIN_D1 // LED back-light (only for ST7789 with backlight control pin) //#define TOUCH_CS PIN_D2 // Chip select pin (T_CS) of touch screen //#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only // ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ###### // Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact //#define TFT_SPI_OVERLAP // In ESP8266 overlap mode the TFT chip select MUST connect to pin D3 // ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ###### // For ESP32 Dev board (only tested with ILI9341 display) #define TFT_MISO 19 #define TOUCH_CS 5 // Chip select pin (T_CS) of touch screen //#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only // For the M5Stack module use these #define lines // ###### EDIT THE PINs BELOW TO SUIT YOUR ESP32 PARALLEL TFT SETUP ###### // The library supports 8 bit parallel TFTs with the ESP32, the pin // Parallel bus is only supported for the STM32 and ESP32 // Tell the library to use 8 bit parallel mode (otherwise SPI is assumed) // The ESP32 and TFT the pins used for testing are: //#define TFT_WR 4 // Write strobe control pin - must use a pin in the range 0-31 //#define TFT_D0 12 // Must use pins in the range 0-31 for the data bus // ###### EDIT THE PINs BELOW TO SUIT YOUR STM32 SPI TFT SETUP ###### // The TFT can be connected to SPI port 1 or 2 //#define TFT_SPI_PORT 2 // SPI port 2 maximum clock rate is 27MHz // Can use Ardiuno pin references, arbitrary allocation, TFT_eSPI controls chip select //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to processor reset // ################################################################################## // Comment out the #defines below with // to stop that font being loaded #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH // Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded // ################################################################################## // Define the SPI clock frequency, this affects the graphics rendering speed. Too // #define SPI_FREQUENCY 1000000 // Optional reduced SPI frequency for reading TFT // The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here: // The ESP32 has 2 free SPI ports i.e. VSPI and HSPI, the VSPI is the default. // Comment out the following #define if "SPI Transactions" do not need to be // Transaction support is needed to work with SD library but not needed with TFT_SdFat // Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex) // #define SUPPORT_TRANSACTIONS |
Beta Was this translation helpful? Give feedback.
-
This is probably related to #923. Thanks for the sketch I will try it sometime this weekend and see where the problem is. |
Beta Was this translation helpful? Give feedback.
-
It will be the commenting out of SET_BUS_WRITE_MODE; that has fixed it. This line puts the bus into "write only" mode. Since SET_BUS_READ_MODE; is called by begin_touch_read_write() it can safely be commented out. I will update the library. It looks like the other libraries are not correctly configuring the SPI bus upon entry and so relies on the previous library leaving the bus in a compatible state. Not a good idea! |
Beta Was this translation helpful? Give feedback.
It will be the commenting out of SET_BUS_WRITE_MODE; that has fixed it. This line puts the bus into "write only" mode.
Since SET_BUS_READ_MODE; is called by begin_touch_read_write() it can safely be commented out. I will update the library.
It looks like the other libraries are not correctly configuring the SPI bus upon entry and so relies on the previous library leaving the bus in a compatible state. Not a good idea!