Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Clash with ethernet and TFT_ILI9163C libraries

  1. #1
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,788

    Clash with ethernet and TFT_ILI9163C libraries

    Hi all

    Trying to get an Ethernet connected display working seem to have something clashing in SPI settings between ethernet and the TFT_ILI9163C, a cut down version of the DHCP printing code reproduces the problem, at least on my install (Windows, Arduino 1.8.5, Teensyduino 1.40, Teensy included TFT and Ethernet versions)

    Code:
    #include <SPI.h>
    #include <Ethernet.h>
    #include <Adafruit_GFX.h>
    #include <TFT_ILI9163C.h>
    
    // Enter a MAC address for your controller below.
    // Newer Ethernet shields have a MAC address printed on a sticker on the shield
    byte mac[] = {
      0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
    };
    
    #define __CS 9
    #define __DC 20
    
    TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC);
    
    void setup() {
      
      Serial.begin(9600);
       //  tft.begin(); // tft.begin here will work
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      }
      // start the Ethernet connection:
      Serial.println("Initialize Ethernet with DHCP:");
      if (Ethernet.begin(mac) == 0) {
        Serial.println("Failed to configure Ethernet using DHCP");
        for (;;)
          ;
      }
    
          tft.begin();// here causes errors with ethernet
      printIPAddress();
       
    }
    
    void loop() {
      switch (Ethernet.maintain()) {
        case 1:
          //renewed fail
          Serial.println("Error: renewed fail");
          break;
    
        case 2:
          //renewed success
          Serial.println("Renewed success");
          //print your local IP address:
          printIPAddress();
          break;
    
        case 3:
          //rebind fail
          Serial.println("Error: rebind fail");
          break;
    
        case 4:
          //rebind success
          Serial.println("Rebind success");
          //print your local IP address:
          printIPAddress();
          break;
    
        default:
          //nothing happened
          break;
      }
    }
    
    void printIPAddress() {
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
    }
    In this case DHCP should be getting a 10.5.x.x address but the printed result is 2.3.10.0, and other more complex ethernet functions fail in various ways as well.

    The Ethernet module is a W5500 clone with CS on 10, and the display pins are immaterial being write only.

    Chasing down into the libraries both use transactions which is good but in TFT_ILI9163C.h write functions there are values going into KINETISK_SPI0.PUSHR which if commented out allow ethernet to work correctly (but breaks the TFT obviously), suggesting something is being set there that clashes with the settings for ethernet SPI. Ethernet appears to use teensy SPIFIFO.h to get at the KINETISK_SPI0.PUSHR but my read of the code there is that it should be overwriting anything left behind by the TFT commands.

    Any suggestions on untangling this would be welcome, still not sure if it is peculiar to this install.

    For anybody else arriving via a search TFT_ILI93XX does work with ethernet but has issues of it's own getting the 128*128 displays to work.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,182
    Two quick things to try.

    1: If you're using any alternate SPI pins (for MISO, MOSI, SCK), try 1.41-beta. An issue with SPIFIFO conflicting with SPI lib alt pins was recently fixed.

    2: Try commenting out the USE_SPIFIFO line near the top of Ethernet's w5100.cpp file. That will cause it to fall back to regular SPI library.

  3. #3
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,788
    Hi Paul, test with the 1.41 beta gets the same result, as did reverting Ethernet to default SPI. Am using the default pins for everything except the tft CS/DC pins

    comparing with the working ili93XX library the actual SPI hardware calls appear to be the same, though it doesn't have the ifdefs for
    #if ARDUINO >= 160
    Unsure how that could be doing anything.

    Have got what I need project wise out of swapping to ili93XX, though not having to do so would be good (ili93XX mirrors the display with default config) so will see if comparing the two tft libraries shows up anything.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •