0

HUZZAH32, SPI and ST7735R TFT?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

HUZZAH32, SPI and ST7735R TFT?

by _gid on Tue Jan 09, 2018 1:15 pm

Hi,

I've been using a Feather M0 Bluefruit with an Adafruit ST7735R 1.44" 128x128 TFT breakout (NOT the FeatherWing) and some simple Hello World GFX code using the Adafruit_ST7735 Arduino library, and it's been working fine. I've also been using a No-name ST7735R 1.8" 128x160 TFT breakout from eBay that's been working fine with the same code (a couple of constants changed).

For some extra oomph (for graphics interpolation) I'm upgrading to a HUZZAH32 Feather, but using the same code I'm getting no results: the Serial Monitor printlns correctly, but the screen just stays completely white.

The code's compiling fine (Adafruit ESP32 Feather board type) and I've tried using the same pinout, variations, both with hardware SPI and software SPI, and nothing seems to work for either screen -- don't worry about the No-name 1.8" though: I don't expect it to work; I just bring it up for comparison. To eliminate a bad board, I've tried this with a second brand-new HUZZAH32 with the same results.

The pinouts I'm using successfully on the M0 and unsuccessfully on the ESP32 Feathers:

Code: Select all | TOGGLE FULL SIZE
   TFT   Feather
   -------------
   Vin → 3V
   Gnd → Gnd
   SCK → SCK (#5)
  MOSI → MOSI (#18)
TFT_CS → A5 (#4)
 RESET → A0 (#26)
   D/C → A1 (#25)

with the appropriate pin configurations in code.

Has the HUZZAH32 been tested with the Arduino ST7735R library and the 1.44" TFT breakout (Product 2088)? Or the FeatherWing? If so, what are the equivalent pin connections and code config for the breakout board?

I've tried all the combinations I can think of, so I'm starting to conclude it's incompatibility of the library.

Unfortunately, I have no other SPI experience as all my other widgets seem to be I2C, so I'm not really sure how to start debugging SPI on HUZZAH32.

Any advice appreciated!

Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>
#include <Adafruit_ST7735.h>
#include <Adafruit_GFX.h>   


#define TFT_CS     A5
#define TFT_DC     A1
#define TFT_RST    A0 
// Also tried using A8-A10


// Hardware SPI:
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

// Have also tried software SPI, on these pins as well as other pins, eg. A6-A10
// #define TFT_SCLK   SCK
// #define TFT_MOSI   MOSI
// Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

void setup(void) {
  Serial.begin(115200);
  Serial.println("\n\nStart");

  tft.initR(INITR_144GREENTAB);
  Serial.println("1");

  tft.fillScreen(ST7735_BLACK);
  Serial.println("2");
 
  tft.setTextColor(ST7735_WHITE);
  Serial.println("3");

  tft.setTextSize(0);
  Serial.println("4");

  tft.setCursor(30,80);
  Serial.println("5");

  tft.println("Hello World!"); 
  Serial.println("6");

  delay(1000);
  Serial.println("done");
}

void loop() {
  Serial.println("loop");
  tft.invertDisplay(true);
  delay(500);
  tft.invertDisplay(false);
  delay(500);
}

_gid
 
Posts: 4
Joined: Thu Mar 03, 2016 6:12 am

Re: HUZZAH32, SPI and ST7735R TFT?

by adafruit_support_mike on Wed Jan 10, 2018 6:07 am

Offhand, I don't know if anyone has tested the ST7735R breakout with an ESP32.

Based on the symptoms you've described, I'd suspect a timing issue though. The M0 is a 48MHz microcontroller, and the ESP32 runs at 240MHz. Displays usually need some time to get up and running, or to process information, but you often get that automatically in the time it takes a microcontroller to execute the code to get to the next message. It isn't unusual to see problems like that pop up when you switch to a much faster device.

That's usually the kind of thing you run down using an oscilloscope and/or logic analyzer.. get a trace of the working system, get a trace of the system that doesn't work, and see where they're different.

adafruit_support_mike
 
Posts: 47875
Joined: Thu Feb 11, 2010 2:51 pm

Re: HUZZAH32, SPI and ST7735R TFT?

by _gid on Fri Jan 12, 2018 7:48 am

Thanks Mike.. that's going to be harder to debug than I hoped, but it makes sense. I'll have a go putting in some delays in the library itself. I don't have an oscilloscope (well, except for one of those pretend handheld things) so it's going to be trial-and-error.

_gid
 
Posts: 4
Joined: Thu Mar 03, 2016 6:12 am

Re: HUZZAH32, SPI and ST7735R TFT?

by adafruit_support_mike on Sat Jan 13, 2018 3:24 am

Try adding delay(1) calls after and code that talks to the display, and if that doesn't help, try adding some in the TFT library itself.

If it's the kind of timing issue I'm thinking about, you can often solve the problem with trial-and-error blind coding. The core problem is giving the external device enough time to process signals, and you can find the places where such a delay would fit by reading the code.

On a separate track, you might want to try using 100-ohm resistors instead of regular jumpers between the microcontroller and the display. Electrical signals move through copper like waves, and fast-moving signals can echo back and forth inside the wire. The rising and falling edges of a 240MHz microcontroller will be fast enough that even a few inches of wire could cause trouble. The resistors will slow things down slightly, and will dissipate the energy that would cause ringing.

adafruit_support_mike
 
Posts: 47875
Joined: Thu Feb 11, 2010 2:51 pm

Re: HUZZAH32, SPI and ST7735R TFT?

by _gid on Sat Jan 20, 2018 2:53 pm

Thanks for the advice. I did try fiddling with delays, both in the library and in the main code. I also tried changing the SPI clock divisor, etc., and then tested it on Espruino (which worked, verifying the hardware)

Back on Arduino, I finally managed to find a combination of pin assignments that worked. It just seems to be a bit picky about the pins chosen. I've succeeded with Hardware SCK and MOSI pins, along with 12, 15 and 32 for CS, RST and DC respectively.

Admittedly, the Feather doesn't flash well with the screen plugged in and drawing power, so I disconnect Vcc and Gnd from the screen when flashing... a bit tedious, but correctable if I get it powered separately.

Anyway, case closed. Thanks!

_gid
 
Posts: 4
Joined: Thu Mar 03, 2016 6:12 am

Re: HUZZAH32, SPI and ST7735R TFT?

by adafruit_support_mike on Sun Jan 21, 2018 4:43 am

Glad to hear you got it working, and thanks for posting your results!

adafruit_support_mike
 
Posts: 47875
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.