ILI9341 with 3V Pro Trinket - Can't get Hardware SPI Working

Hopefully someone here has guidance on what I'm missing.

I purchased a cheap 2.2" TFT screen compatible with the ILI9341 library. Trying to use it with an Adafruit 3V Pro Trinket at the moment. I'm using the Adafruit_ILI9341.h library to run the show.

My reason for wanting to get hardware SPI working is because the draw rate I've got right now is sloooow. The Adafruit GFX fillScreen() method takes almost two and a half seconds to fill my screen in with red. My understanding (and I could be totally wrong) is that I've been using software SPI when I have this thing working, and hardware SPI would be dramatically faster. Unfortunately, I can't seem to get it working.

In terms of wiring, I've got

  • Pin 9 to the TFT DC;
  • Pin 10 to the TFT CS;
  • Pin 11 for TFT_MOSI;
  • Pin 12 for TFT_MISO;
  • Pin 8 for TFT_RST;
  • Pin 13 for TFT_CLK; and
  • Pin 6 hooked to the TFT LCD Backlight.

This Pinout seems consistent with what is listed on the Trinket Page. I have checked, and double-checked, and triple-checked these connections. I have gone as far as reflowing all of my pins just in case there was something dodgy in the mix, but that didn't seem to resolve anything.

I can get the device working if I use the following constructor:

#define TFT_DC 9
#define TFT_CS 10
#define TFT_MOSI 11
#define TFT_MISO 12
#define TFT_RST 8
#define TFT_CLK 13 //Arduino SCK
#define TFT_LCD 6

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);/code]

My understanding is that this constructor implements the Software SPI? In any event, this works, and I get a screen that performs everything I need it to with the Adafruit_GFX library, but it's slow. Very slow. 

There is an alternative constructor that I have tried in lieu of the one above:
[code]
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

This compiles and uploads fine. However, nothing happens on the display if I use this constructor. I get a white screen (presumably because the TFT_LCD backlight is powered) but no other data or displays.

Thinking that maybe it was something wrong with my Pro Trinket, I switched to the exact same setup but used an Uno R3 instead of the Pro Trinket. Same wiring schematic and everything. I figured since the Uno had a serial monitor I might be able to get some better information to debug with. I tried the graphicstest.ino sketch to see if the debugging lines got me anything useful, and...

ILI9341 Test!
Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark                Time (microseconds)
Screen fill              1448928
Text                     144900

... and so on. The 0x0 means the serial communication isn't working here. It's basically the exact same results on the Uno - if I use the long constructor that declares all the pins, screen works fine, but slow. The short one gives me only a white screen, consistent with a lit backlight and nothing else.

My sketch is below. I tried to keep things as simple as possible.

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

#define TFT_DC 9
#define TFT_CS 10
#define TFT_MOSI 11
#define TFT_MISO 12
#define TFT_RST 8
#define TFT_CLK 13 //Arduino SCK
#define TFT_LCD 6

//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

void setup()
{
  tft.begin();
  pinMode(TFT_LCD, OUTPUT);
  analogWrite(TFT_LCD,255);
  tft.fillScreen(ILI9341_RED);
}

void loop()
{   
}

Anyone able to point me at what I'm missing here? I've tried other libraries (in particular, I liked the Pixel library because it was pretty fast, but it didn't have any built-in font options and I don't have a ton of memory to spare on my project for font data).

You are hit by the standard Adafruit trick. Add the RST pin to the hardware SPI constructor and the screen should be fine.

You should find that other ILI9341 libraries will work too e.g. ILI9341_due and ILI9341_PDQ.

You should use level shifters on a 5V Uno. Your 3V Pro Trinket does not need level shifters.

David.

david_prentice:
You are hit by the standard Adafruit trick. Add the RST pin to the hardware SPI constructor and the screen should be fine.

I could kiss you. That did it. thank you!

Look at it from Adafruit's point of view. They design and sell hardware. They put a lot of effort into writing/supporting the software.

They design their hardware to "work" without a RST argument.
If Chinese displays don't have a pullup, Adafruit can sell more of their own hardware.

David.

Totally makes sense, and I'm not faulting them for it. I often use their products largely because I am amateurish at best in this domain, and they remove a lot of the sharp edges from issues like this. That said, the project I'm working on at the moment had some very specific requirements for the dimensions of the screen it could fit, and none of their products were suitable, but this cheapo Chinese unit was.

Thanks again!