IL9341 LCD Display with Hardware SPI and Ucglib on Arduino Micro

Hi!

I am currently trying to control an IL9341 LCD Display using my Arduino Micro.

This works fine when I use the SWSPI mode like so:
Ucglib_ILI9341_18x240x320_SWSPI screen(13, 11, 6, 5, 4);

However, that is horribly slow. One screen fill takes ~3 seconds

So I tried to use Hardware SPI to increase performance and used the following code:
Ucglib_ILI9341_18x240x320_HWSPI screen(6, 5, 4);

No matter what I do, i can only get a white screen. I've double-checked that everything is connected correctly, that the data line is connected to the MOSI pin, and the clock line to the SCK pin of the Micro according to the pinout on arduino.cc.

For conversion from 5V->3V I use a resistor voltage divider with 5.6kOhm and 2.7kOhm. That thing works for SWSPI so I don't think it's the problem

Unfortunately, I do not own an oscilloscope but with my multimeter I could determine that the Clock SPI pin was always Low (0V) and the MOSI pin always HIGH (5V). No change whatsoever. I don't know if that is due to the inaccuracy of my meter or if the hardware SPI of my Arduino Micro just does not work.

I have even tried using different versions of the Ucglib library, without success.

I've been trying every solution that I find for hours now but I can't get it to work.

Any ideas? I am new to this so maybe I am missing something obvious here.
Thank you very much in advance!

-Twometer

An Arduino Micro is a miniature Leonardo with SPI on different hardware pins i.e. SCK on D15, MOSI on D16.
An Arduino Pro Mini is a miniature Uno without USB.

It is very important to use the correct board name e.g. Uno or Uno clone.

David.

Edit. Added Digital numbers (for Leonardo).

Hi David,
thank you for the quick answer!

I have an original Arduino Micro, no clone.

My SCK and MOSI lines from the display are connected to those dedicated hardware pins, but I still get a white screen.
As I said, when I test those hardware pins with my multimeter they do not seem to carry any signal.

Thanks again
Twometer

david_prentice:
An Arduino Micro is a miniature Leonardo with SPI on different hardware pins i.e. SCK on D15, MOSI on D16.

Aren't they the pins labelled MOSI/SCK?

Yes, you are using the correct pins from the module. But SCK pin is digital#15 in Arduino digitalWrite().
And MOSI is digital#16.

Your SW constructor is using 13, 11

Ucglib_ILI9341_18x240x320_SWSPI screen(13, 11, 6, 5, 4);

digital#13 is bottom right hand corner of your diagram.
digital#11 is 2nd from bottom on left.

Wire your screen to SCK, MOSI pins at top right and top left. And test with

Ucglib_ILI9341_18x240x320_HWSPI screen(15, 16, 6, 5, 4);

Then you can change to the HW constructor:

Ucglib_ILI9341_18x240x320_SWSPI screen(6, 5, 4);

David.

Edit. Ucglib has extensive support for Fonts. It is not particularly fast for graphics.
There are lots of Adafruit_GFX style libraries for SPI ILI9341. They are faster but are less good with text.

david_prentice:
Wire your screen to SCK, MOSI pins at top right and top left. And test with

Ucglib_ILI9341_18x240x320_HWSPI screen(15, 16, 6, 5, 4);

Ah now I understand, thanks.
I have now tested that and with Software SPI on Digital Pin 15 and 16 it still works fine, but again, using Hardware SPI fails. White screen again.

For Hardware SPI I tried this

Ucglib_ILI9341_18x240x320_HWSPI screen(6, 5, 4);

I also tried

Ucglib_ILI9341_18x240x320_SWSPI screen(6, 5, 4);

Both just light the backlight, no pixel data.

I'm going to test with the Adafruit Library now

Leonardo / Micro has never been very popular.

But I am sure that Ucglib uses the regular SPI.h library from the Arduino. So it should work fine on your ATmega32U4 chip.

If you have verbose compilation checked in Preferences, the Build Report will say which libraries and versions were used. e.g.

Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.1\hardware\arduino\avr\libraries\SPI 
Using library Ucglib at version 1.5.2 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Ucglib

David.

Yes, I also think it uses the SPI library, but interestingly my verbose log does not state the version of the SPI library, nor any other library. I have enabled verbose output during compilation.

When I compile the Adafruit graphicstest however, it has the following entries

Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Using library Adafruit-GFX-Library-master at version 1.2.9 in folder: C:\Users\twome\Documents\Arduino\libraries\Adafruit-GFX-Library-master 
Using library Adafruit_ILI9341 at version 1.2.0 in folder: C:\Users\twome\Documents\Arduino\libraries\Adafruit_ILI9341

Twometer:
I'm going to test with the Adafruit Library now

I have tested it with the Adafruit Library (graphicstest) and I have the same problem. Hardware shows a white screen and software works fine. However, it is only a little bit faster than Ucglib. These are the timings from the Adafruit graphicstest in Software

Text                     927312
Lines                    8603128
Horiz/Vert Lines         1493740
Rectangles (outline)     951704
Rectangles (filled)      37894080
Circles (filled)         5351904
Circles (outline)        3743416
Triangles (outline)      1959560
Triangles (filled)       12593380
Rounded rects (outline)  1791844
Rounded rects (filled)   41211552

I have now managed to get the output for the Ucglib program

Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Using library URTouch in folder: C:\Users\twome\Documents\Arduino\libraries\URTouch (legacy)
Using library Ucglib at version 1.5.2 in folder: C:\Users\twome\Documents\Arduino\libraries\Ucglib

Okay, I have now finally fixed it. I read on the Arduino page that the library won't work if the Slave Select pin is not set as Output.
After adding this simple line of code

  pinMode(SS, OUTPUT);

everything works fine!

Anyways, Thank you very much for your help David!

-Twometer