[SOLVED]HXD8357D White screen MKR1010

I'm not having any luck getting my Adafruit 3.5" Touchscreen to work with my WiFi10110. All I get is a blank white screen.

I'm trying to do the Adafruit tutorial using the graphicstest.ino

The wiring is:

TFT pins -to- WiFi1010 pins

Gnd -to- Gnd
3-5v -to- 3.3v
CLK -to- D9 (SCK)
MISO -to- D10 (MISO)
MOSI -to- D8 (MOSI)
CS -to- D7
DC -to- D6
IM2 -to- 3.3v

And the sketch as loaded:

/***************************************************
  This is our library for the Adafruit HX8357D Breakout
  ----> http://www.adafruit.com/products/2050

  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/

#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_HX8357.h"

// These are 'flexible' lines that can be changed
#define TFT_CS 7
#define TFT_DC 6
#define TFT_RST -1 // RST can be set to -1 if you tie it to Arduino's reset

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, TFT_RST);

// SoftSPI - note that on some processors this might be *faster* than hardware SPI!
//Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, MOSI, SCK, TFT_RST, MISO);



void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("HX8357D Test!"); 

  tft.begin();

  // read diagnostics (optional but can help debug problems)
  uint8_t x = tft.readcommand8(HX8357_RDPOWMODE);
  Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(HX8357_RDMADCTL);
  Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(HX8357_RDCOLMOD);
  Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(HX8357_RDDIM);
  Serial.print("Image Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(HX8357_RDDSDR);
  Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); 
  
  Serial.println(F("Benchmark                Time (microseconds)"));

  tft.setRotation(1);

  Serial.print(F("Text                     "));
  Serial.println(testText());
  delay(500);

  Serial.print(F("Lines                    "));
  Serial.println(testLines(HX8357_CYAN));
  delay(500);

  Serial.print(F("Rectangles (outline)     "));
  Serial.println(testRects(HX8357_GREEN));
  delay(500);

  tft.fillScreen(HX8357_BLACK);
  Serial.print(F("Circles (outline)        "));
  Serial.println(testCircles(10, HX8357_RED));
  delay(500);


  Serial.print(F("Triangles (outline)      "));
  Serial.println(testTriangles());
  delay(500);

  Serial.print(F("Triangles (filled)       "));
  Serial.println(testFilledTriangles());
  delay(500);


  Serial.print(F("Rounded rects (outline)  "));
  Serial.println(testRoundRects());
  delay(500);

  Serial.print(F("Rounded rects (filled)   "));
  Serial.println(testFilledRoundRects());
  delay(500);

  Serial.println(F("Done!"));
}


void loop(void) {
  for(uint8_t rotation=0; rotation<4; rotation++) {
    tft.setRotation(rotation);
    testText();
    delay(1000);
  }
}

unsigned long testFillScreen() {
  unsigned long start = micros();
  tft.fillScreen(HX8357_RED);
  tft.fillScreen(HX8357_GREEN);
  tft.fillScreen(HX8357_BLUE);
  tft.fillScreen(HX8357_WHITE);
  return micros() - start;
}


unsigned long testText() {
  tft.fillScreen(HX8357_BLACK);
  unsigned long start = micros();
  tft.setCursor(0, 0);
  tft.setTextColor(HX8357_WHITE);  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(HX8357_YELLOW); tft.setTextSize(2);
  tft.println(1234.56);
  tft.setTextColor(HX8357_RED);    tft.setTextSize(3);
  tft.println(0xDEADBEEF, HEX);
  tft.println();
  tft.setTextColor(HX8357_GREEN);
  tft.setTextSize(5);
  tft.println("Groop");
  tft.setTextSize(2);
  tft.println("I implore thee,");
  tft.setTextSize(1);
  tft.println("my foonting turlingdromes.");
  tft.println("And hooptiously drangle me");
  tft.println("with crinkly bindlewurdles,");
  tft.println("Or I will rend thee");
  tft.println("in the gobberwarts");
  tft.println("with my blurglecruncheon,");
  tft.println("see if I don't!");
  
  tft.setTextColor(HX8357_WHITE);
  tft.println(F("Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or conversations?'"));

tft.println(F("So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her."));

tft.println(F("There was nothing so very remarkable in that; nor did Alice think it so very much out of the way to hear the Rabbit say to itself, 'Oh dear! Oh dear! I shall be late!' (when she thought it over afterwards, it occurred to her that she ought to have wondered at this, but at the time it all seemed quite natural); but when the Rabbit actually took a watch out of its waistcoat-pocket, and looked at it, and then hurried on, Alice started to her feet, for it flashed across her mind that she had never before seen a rabbit with either a waistcoat-pocket, or a watch to take out of it, and burning with curiosity, she ran across the field after it, and fortunately was just in time to see it pop down a large rabbit-hole under the hedge."));

tft.println(F("In another moment down went Alice after it, never once considering how in the world she was to get out again."));

tft.println(F("The rabbit-hole went straight on like a tunnel for some way, and then dipped suddenly down, so suddenly that Alice had not a moment to think about stopping herself before she found herself falling down a very deep well."));

tft.println(F("Either the well was very deep, or she fell very slowly, for she had plenty of time as she went down to look about her and to wonder what was going to happen next. First, she tried to look down and make out what she was coming to, but it was too dark to see anything; then she looked at the sides of the well, and noticed that they were filled with cupboards and book-shelves; here and there she saw maps and pictures hung upon pegs. She took down a jar from one of the shelves as she passed; it was labelled 'ORANGE MARMALADE', but to her great disappointment it was empty: she did not like to drop the jar for fear of killing somebody, so managed to put it into one of the cupboards as she fell past it."));
  
  return micros() - start;
}

unsigned long testLines(uint16_t color) {
  unsigned long start, t;
  int           x1, y1, x2, y2,
                w = tft.width(),
                h = tft.height();

  tft.fillScreen(HX8357_BLACK);

  x1 = y1 = 0;
  y2    = h - 1;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = w - 1;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t     = micros() - start; // fillScreen doesn't count against timing


  return micros() - start;
}

unsigned long testFastLines(uint16_t color1, uint16_t color2) {
  unsigned long start;
  int           x, y, w = tft.width(), h = tft.height();

  tft.fillScreen(HX8357_BLACK);
  start = micros();
  for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
  for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);

  return micros() - start;
}

unsigned long testRects(uint16_t color) {
  unsigned long start;
  int           n, i, i2,
                cx = tft.width()  / 2,
                cy = tft.height() / 2;

  tft.fillScreen(HX8357_BLACK);
  n     = min(tft.width(), tft.height());
  start = micros();
  for(i=2; i<n; i+=6) {
    i2 = i / 2;
    tft.drawRect(cx-i2, cy-i2, i, i, color);
  }

  return micros() - start;
}

unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
  unsigned long start, t = 0;
  int           n, i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(HX8357_BLACK);
  n = min(tft.width(), tft.height());
  for(i=n; i>0; i-=6) {
    i2    = i / 2;
    start = micros();
    tft.fillRect(cx-i2, cy-i2, i, i, color1);
    t    += micros() - start;
    // Outlines are not included in timing results
    tft.drawRect(cx-i2, cy-i2, i, i, color2);
  }

  return t;
}

unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;

  tft.fillScreen(HX8357_BLACK);
  start = micros();
  for(x=radius; x<w; x+=r2) {
    for(y=radius; y<h; y+=r2) {
      tft.fillCircle(x, y, radius, color);
    }
  }

  return micros() - start;
}

unsigned long testCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int           x, y, r2 = radius * 2,
                w = tft.width()  + radius,
                h = tft.height() + radius;

  // Screen is not cleared for this one -- this is
  // intentional and does not affect the reported time.
  start = micros();
  for(x=0; x<w; x+=r2) {
    for(y=0; y<h; y+=r2) {
      tft.drawCircle(x, y, radius, color);
    }
  }

  return micros() - start;
}

unsigned long testTriangles() {
  unsigned long start;
  int           n, i, cx = tft.width()  / 2 - 1,
                      cy = tft.height() / 2 - 1;

  tft.fillScreen(HX8357_BLACK);
  n     = min(cx, cy);
  start = micros();
  for(i=0; i<n; i+=5) {
    tft.drawTriangle(
      cx    , cy - i, // peak
      cx - i, cy + i, // bottom left
      cx + i, cy + i, // bottom right
      tft.color565(200, 20, i));
  }

  return micros() - start;
}

unsigned long testFilledTriangles() {
  unsigned long start, t = 0;
  int           i, cx = tft.width()  / 2 - 1,
                   cy = tft.height() / 2 - 1;

  tft.fillScreen(HX8357_BLACK);
  start = micros();
  for(i=min(cx,cy); i>10; i-=5) {
    start = micros();
    tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(0, i, i));
    t += micros() - start;
    tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(i, i, 0));
  }

  return t;
}

unsigned long testRoundRects() {
  unsigned long start;
  int           w, i, i2,
                cx = tft.width()  / 2 ,
                cy = tft.height() / 2 ;

  tft.fillScreen(HX8357_BLACK);
  w     = min(tft.width(), tft.height());
  start = micros();
  for(i=0; i<w; i+=8) {
    i2 = i / 2 - 2;
    tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 100, 100));
  }

  return micros() - start;
}

unsigned long testFilledRoundRects() {
  unsigned long start;
  int           i, i2,
                cx = tft.width()  / 2 + 10,
                cy = tft.height() / 2 + 10;

  tft.fillScreen(HX8357_BLACK);
  start = micros();
  for(i=min(tft.width(), tft.height()) - 20; i>25; i-=6) {
    i2 = i / 2;
    tft.fillRoundRect(cx-i2, cy-i2, i-20, i-20, i/8, tft.color565(100, i/2, 100));
  }

  return micros() - start;
}

the Serial monitor output is:

HX8357D Test!
Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark Time (microseconds)
Text 612575
Lines 1845967
Rectangles (outline) 142240
Circles (outline) 795002
Triangles (outline) 369557
Triangles (filled) 2477187
Rounded rects (outline) 238455
Rounded rects (filled) 5056792
Done!

I've thoroughly checked all the wiring including continuity and all seems in order. I just can't see what I am missing.

I've used that display with an UNO and ESP8266 using Adafruit's libraries and am currently using it with an ESP32 using the TFT_eSPI library. No issues. The only thing that caught my eye is that you are holding IM2 high. I've never done that and the Adafruit instructions say the IM pins are for advanced use and their tests. Why are you holding it high?

Tying IM2 high puts the display in SPI mode. you can either solder the jumper on the backside or jumper the IM2 pin.

SPI Mode Jumpers

Before you start, we'll need to tell the display to put us in SPI mode so it will know which pins to listen to. To do that, we have to connect the IM2 pin to 3.3V. The easiest way to do that is to solder closed the IM2 jumper on the back of the PCB.
If you really don't want to solder, you can also wire the breakout pin to the 3vo pin, just make sure you don't tie it to 5V by accident! For that reason, we suggest going with the solder-jumper route.

Hmm. Well, now that you mention it...yes, I did that...soldered the jumper (mea culpa: did it about 10 years ago!) Sorry I can't be of help.

Well I've been at it all weekend with no luck.

• Hardware SPI = white screen of death

• Software SPI = white screen of death

• try display with Uno = display works as expected

• connect wifi1010 SPI pins to cheap logic Analyzer = expected output (i think)

But no matter what when I put this display and the wifi1010 together I get nothing but a white screen.

At this point, I'd give the TFT_eSPI lib a try.

Yes, I will start exploring other libraries tonight after work .

Was hoping @david_prentice would show up to save the day.

  1. Make the solder-bridge (IM2) as shown in https://learn.adafruit.com/adafruit-3-5-color-320x480-tft-touchscreen-breakout/spi-wiring-and-test

  2. Install libraries

  3. Connect to Uno as shown in photo from link.

  4. Run the examples

  5. Now edit one of the examples to use the "Software SPI constructor". i.e. with the specific SCK, MOSI, MISO arguments. e.g.

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, TFT_RST);

// SoftSPI - note that on some processors this might be *faster* than hardware SPI!
//Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, MOSI, SCK, TFT_RST, MISO);
  1. Verify that the example(s) work ok. (they will be a bit slower.)

  2. Now connect the display to your WiFi10110 board.

  3. you can use the same pins as the Uno

  4. Verify that the example(s) work with the bit-banged constructor.

I would expect the Software SPI (bit-banged) constructor to work on any Arduino. You should be able to use random GPIO pins.

  1. you can move the MOSI, MISO, SCK wires to the specific hardware pins on the Wifi0110.
  2. edit the defines to match.
  3. verify the SoftSPI constructor.
  4. verify the hardware SPI constructor.

David.

Well today was the first chance I've had to play with this since last weekend and I'm still coming up empty.

I followed @david_prentice 's instructions above and all went well until step #9 where once again all I get is a white screen.

I did find out that last week I was using the logic analyzer incorrectly. and now that I've worked that out I can see that there is not a recognizable SPI signal coming from the WiFi1010. It toggles the pins some, but not anything resembling a SPI signal.

I also tried the TFT-eSPI library but only get a white screen there also.

I don't know what else I can try. Any more Ideas? I do have enough pins available for 8 bit parallel but I really don't think that's going to work either.

Does anyone know of a 480 pixel wide screen that is known to work with the MKR boards.

GPIO13 is used by Serial RX. So you can't use the "same" pins as on the Uno.

I suggest that you use GPIO6 - GPIO10 instead of the Uno's 8-13.
In fact use the hardware SPI pins e.g. MOSI = GPIO8

I would expect the Software SPI constructor to work with random pins.
Obviously the Hardware SPI requires the specific pins.

David.

For the software SPI i used pins 2-7 on both the Uno and WiFi1010 . I also tried pins 6-10 using both the hard and soft constructors

Unfortunately unlike for my st7735 display(which works) the HX_8357d hardware constructor does not allow specifying the hardware SPI pins. I did print the values for MOSI, SCK, and MISO and they are correct for the wifi1010 (8, 9, and 10 respectively).

EDIT: I was incorrect my st7735 is using software SPI on the hardware pins(6-9)

Follow message #8 but for your ST7735 display.
I would expect it to run on the Uno and on the Wifi1010 with the SoftSPI constructor.

Then use the Wifi1010 hardware pins. Try the HW SPI constructor.

This will confirm whether your Wifi1010 is faulty.

You have not said whether the HX8357D works on a Uno. The link in #8 shows you the exact wiring.
This will confirm whether your HX8357D is faulty.

David.

Good Morning David,

I ran the requested tests as thoroughly as possible this morning. I also changed breadboards and used brand new dupont jumper wires.
Here are the results:

Uno, ST7735, HardSPI = Success
Uno, ST7735, SoftSPI on hardware SPI pins = Success
Uno, ST7735, SoftSPI on random pins = Success

Uno, HX8357D, HardSPI = Success
Uno, HX8357D, SoftSPI on hardware SPI pins = Success
Uno, HX8357D, SoftSPI on random pins = Success

WiFi1010, ST7735, HardSPI = Success
WiFi1010, ST7735, SoftSPI on hardware SPI pins = Success
WiFi1010, ST7735, SoftSPI on random pins = Success

WiFi1010, HX8357D, HardSPI = Fail - White Screen
WiFi1010, HX8357D, SoftSPI on hardware SPI pins = Fail - White Screen
WiFi1010, HX8357D, SoftSPI on random pins = Fail - White Screen

I also accidentally discovered that on the Uno the ST7735 graphicsTest.ino works on the HX8357D and vice versa although pixels are incorrect. this holds for the WiFi1010 except of course the HX8357D still doesn't work with the WiFi1010 under any circumstances.

I seem to still be having issues using my Logic Analyzer (Pulseview is known to be very buggy on Windows) I did get what I believe to be good reading's today. Here is a screen grab of the readings I got from the WiFi1010 with HX8357D, HardSPI:

I also checked voltage and am getting 2.98v at Vin of the tft. Should be ok right?

EDIT: Logic Analyzer was connected to SPI pins of the display

I'm at my wits end. After 2 weekends I haven't made any progress at all. As far as I can tell it should be working.

I am starting to wonder if it could be a power issue. I get 3.3v when tft-Vin is not connected and 2.98v when it is. A drop of ~32mV
Current measures at ~145mA, However I can't seem to locate a rating for the 3,3v regulator on the WiFi1010. Unfortunately I don't have another 3.3v power supply on hand. I have ordered one.

I am running out of time, I need this project up and running in ~3-4 weeks and there is a lot left to do. So I have ordered one of these as back up if I can't solve the problem this week. It will be added work porting it over but what ya gonna do.

Have you asked at the Adafruit forum? Also, can you get any SPI device to work with your WiFi1010?

I haven't tried there maybe I should.
And as outlined in post #13 my ST7735 display works fine on the WiFi1010 via SPI.

Oh yeah, right. Maybe you have a bum HX8357D. It does happen. If you give them the information in #13, they may send you a new one.

Your tests have shown that HX8357 is fine and the ST7735 is fine too.

I have made no attempt to look at Adafruit's SPI code. I suspect that there is some weird conditional branch in the depths of Adafruit_SPITFT.cpp

I don't have a SPI HX8357 and I don't have a Wifi0110 board.
Arduino Hardware SPI libraries are pretty crap for some of these ARM boards. Which is why I was suggesting SoftSPI first.

David.

Well I finally got this thing to work today.
I found a posting on Adafruit from 2014 where someone had this problem while using this display with a Due and got it to work using 5v on the TFT Vin and asked if that would be a problem on the 3.3v Due. The Adafruit Rep said that was fine.

So I connected TFT Vin to 5v and it is now working correctly on both hard and softSPI.

Thanks for all the help guys.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.