Go Down

Topic: ILI9341 2.2" QVGA white screens when I try to use hwspi with Mega2560 (Read 331 times) previous topic - next topic

kfitzm3

Hey! I've got a red ili9341. I've got it hooked up to a mega 2560 r3. Pinout is below. When I run the graphicstest example from the Adafruit_ILI9341 library using the software spi constructor and defining all of the pins it works, but very slowly. I want to be able to use the hardware spi constructor, but the display refuses to do anything but display white, and sometimes flicker. When using hwspi graphicstest returns 0x0 for all of its test results and appears to run very quickly even though the screen does nothing. I'm using voltage dividers on the SCK, MOSI, DC, RESET, and CS pins with resistances of 22k and 47k, set up as follows. Mega pin -> 22k -> display -> 47k -> GND

This is what I've tried:
Tying the reset pin to the arduino reset pin and removing TFT_RST from the hwspi constructor, doing the manual reset digitalWrite and delay(10) thing everyone always suggests because of the white screen sleep mode, and switching to ILI9341_AS. Also tried voltage dividing MISO haha.

Display -> Mega 2560 pin
MISO -> 50
LED -> 100ohms -> 5V
MOSI -> VD -> 51
SCK -> VD -> 52
CS -> VD -> 53
DC -> VD -> 49
RESET -> VD -> 48
GND to GND
Vcc to 5V, 100 uF capacitor across the power pins of the display

Ultimately I'm trying to use the Adafruit_imagereader library to load and draw bmps from a microsd card also tied to hwspi. When I tried to just go for that, the white screening began. I figured that since the library made a big deal about both the sd and display needing hwspi I should figure out why that constructor isn't working for me. Let me know if you need my code, but I didn't change anything from the base Adafruit_ILI9341 library and example except to specify the mega hwspi pins and my cs/dc/rst pins.

Update: also tried connecting VCC to 3.3V instead. Still whitescreen. Here's the display: http://www.lcdwiki.com/2.2inch_SPI_Module_ILI9341_SKU:MSP2202

Thanks!

david_prentice

Your screen should work fine with the potential dividers.   22k + 47k are pretty high values.  4k7 + 10k would seem more suitable.

U1 is a 3.3V regulator that expects 5V input.
Q1 is a transistor to switch the LED backlight via GPIO.

Always test a library with the software constructor first.    Then you know you have got the wiring correct and working before you try the HW SPI constructor.

All output signals require level shifting.    MISO does not.

I always use proper 3.3V Arduinos e.g. 3V switchable Uno clones.   Much easier.

David.

kfitzm3

David,

Thanks for the tips. U1 is closed and J1 is open, per what I've seen most people set up these boards with. I switched down to 4k7 and 10k. Software spi constructor runs great still, but I don't know how to go about debugging the hwspi white screen in this case. Shouldn't it just work with the hwspi pins? I've been pulling my hair out big time over this.


Yeah I'm considering switching over, 3v3 logic would be nice!

david_prentice

Post both of your constructors.

Other eyes might spot something.

But your wiring from #0 looks ok for HW SPI.   SW SPI works.   So HW SPI should work too.

Note that Adafruit are forever fiddling with their libraries.
Quote your library version numbers.
Make sure you don't have multiple libraries.

David.

kfitzm3

I'll rework the circuit, cleanup my Arduino filesys, update the IDE and libraries, and get some more eyes on it. Thanks for looking at my problem.
EDIT: Did all of the above. Still white screen with hwspi and functions ok with swspi.

Constructors:
Code: [Select]

#define TFT_DC 49
#define TFT_CS 53
#define TFT_RST 48
#define TFT_MOSI 51
#define TFT_CLK 52
#define TFT_MISO 50

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);


Version numbers (I know the bottom two are right - not sure what the heck is happening w SPI):
Code: [Select]
Using library SPI at version 1.0 in folder: /private/var/folders/th/yhd_876n1cv3y157bc7312s80000gn/T/AppTranslocation/970FE6AA-EFE9-4A9C-8CF4-5EA7AFA4910F/d/Arduino 2.app/Contents/Java/hardware/arduino/avr/libraries/SPI
Using library Adafruit_GFX_Library at version 1.7.5 in folder: /Users/kfitzm3/Documents/Arduino/libraries/Adafruit_GFX_Library
Using library Adafruit_ILI9341 at version 1.5.4 in folder: /Users/kfitzm3/Documents/Arduino/libraries/Adafruit_ILI9341

david_prentice

Normally SPI will be under C:/Program Files/Arduino

Everything else looks fine.

David.

Go Up