Go Down

Topic: Serial SPI - 2.2" TFT LCD - ILI9341 (Read 107687 times) previous topic - next topic

K5CZ

Nov 20, 2013, 05:38 pm Last Edit: Nov 20, 2013, 06:01 pm by K5CZ Reason: 1
I got 2.2' TFT LCD: TFT01-2.2SP, but I am not able find proper wiring for Arduino Mega 2560. Has anyone of you this TFT working?

Code: [Select]

Description:
   Operating Voltage: 5v/3.3v
   material: plastic
   Quantity: 1PC
   Size : 67mmX40mm/2.63''x1.57''
   Color : as show the picture
   Congroller: ILI9341
   Resolution: QVGA 240*320 Dots
   Package includes:
    1pc X  2.2 Inch SPI TFT LCD Serial Port Module




I tried connect as follows
Code: [Select]

VCC - +5V
GND - GND
#define _cs   53 //SS
#define _rst  42 //RESET
#define _dc   43 //D/C
#define _mosi 51 //SDI(MOSI)
#define _sclk 52 //SCK
LED - +3.3V
#define _miso 50 //SDO(MISO)

Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);


K5CZ

Also I tried Seeed Studio library, but I do not understand this

Code: [Select]
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

#define TFT_CS_LOW  {DDRE |= 0x08;PORTE &=~ 0x08;}
#define TFT_CS_HIGH {DDRE |= 0x08;PORTE |=  0x08;}
#define TFT_DC_LOW  {DDRH |= 0x08;PORTH &=~ 0x08;}
#define TFT_DC_HIGH {DDRH |= 0x08;PORTH |=  0x08;}
#define TFT_BL_OFF  {DDRH |= 0x10;PORTH &=~ 0x10;}
#define TFT_BL_ON   {DDRH |= 0x10;PORTH |=  0x10;}
#define TFT_RST_OFF {DDRD |= 0x10;PORTD |=  0x10;}
#define TFT_RST_ON  {DDRD |= 0x10;PORTD &=~ 0x10;}

#define YP A2   // must be an analog pin, use "An" notation!
#define XM A1   // must be an analog pin, use "An" notation!
#define YM 54   // can be a digital pin, this is A0
#define XP 57   // can be a digital pin, this is A3

#elif defined(__AVR_ATmega32U4__)

#define TFT_CS_LOW  {DDRC |= 0x40;PORTC &=~ 0x40;}
#define TFT_CS_HIGH {DDRC |= 0x40;PORTC |=  0x40;}
#define TFT_DC_LOW  {DDRD |= 0x80;PORTD &=~ 0x80;}
#define TFT_DC_HIGH {DDRD |= 0x80;PORTD |=  0x80;}
#define TFT_BL_OFF  {DDRE |= 0x40;PORTE &=~ 0x40;}
#define TFT_BL_ON   {DDRE |= 0x40;PORTE |=  0x40;}
#define TFT_RST_OFF {DDRD |= 0x10;PORTD |=  0x10;}
#define TFT_RST_ON  {DDRD |= 0x10;PORTD &=~ 0x10;}

#define YP A2   // must be an analog pin, use "An" notation!
#define XM A1   // must be an analog pin, use "An" notation!
#define YM 18   // can be a digital pin, this is A0
#define XP 21   // can be a digital pin, this is A3

#else
#define TFT_CS_LOW  {DDRD |= 0x20;PORTD &=~ 0x20;}
#define TFT_CS_HIGH {DDRD |= 0x20;PORTD |=  0x20;}
#define TFT_DC_LOW  {DDRD |= 0x40;PORTD &=~ 0x40;}
#define TFT_DC_HIGH {DDRD |= 0x40;PORTD |=  0x40;}
#define TFT_BL_OFF  {DDRD |= 0x80;PORTD &=~ 0x80;}
#define TFT_BL_ON   {DDRD |= 0x80;PORTD |=  0x80;}
#define TFT_RST_OFF {DDRD |= 0x10;PORTD |=  0x10;}
#define TFT_RST_ON  {DDRD |= 0x10;PORTD &=~ 0x10;}


#define YP A2   // must be an analog pin, use "An" notation!
#define XM A1   // must be an analog pin, use "An" notation!
#define YM 14   // can be a digital pin, this is A0
#define XP 17   // can be a digital pin, this is A3

#endif


specifically that part
Code: [Select]

#define TFT_CS_LOW  {DDRE |= 0x08;PORTE &=~ 0x08;}
#define TFT_CS_HIGH {DDRE |= 0x08;PORTE |=  0x08;}
#define TFT_DC_LOW  {DDRH |= 0x08;PORTH &=~ 0x08;}
#define TFT_DC_HIGH {DDRH |= 0x08;PORTH |=  0x08;}
#define TFT_BL_OFF  {DDRH |= 0x10;PORTH &=~ 0x10;}
#define TFT_BL_ON   {DDRH |= 0x10;PORTH |=  0x10;}
#define TFT_RST_OFF {DDRD |= 0x10;PORTD |=  0x10;}
#define TFT_RST_ON  {DDRD |= 0x10;PORTD &=~ 0x10;}


What are these pins?

Trixi

This looks like a kind of pin-mapping for the connection of the TFT.
As i saw in the datasheet you need 2 power sources ?, and the whole thing is driven bei SPI.

Quote

SDO: Serial clock output
LED: 3.4V Power Supply pin
SCL: Serial clock input
SDA / SDI: Serial data input
DC: Data / Command selection
RST: Reset, Low level active
CS: Chip Selection, Low level active
GND: Ground
VDD33: 3.3V Power Supply pin
UTFT Support



GND & Vcc is for the circuit, LED is power for led.

Did you connect RESET and is this HIGH or LOW ?
Dum spiro, spero - if you find my posting helpful, please click my Karma :)

raschemmel

Am I missing something ?
I don't see any SPI transfer commands.
Where is the rest of you code.
All I see is definitions.
Can you please photograph your interface so we can see where all the wires go ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

K5CZ

#4
Nov 20, 2013, 06:38 pm Last Edit: Nov 23, 2013, 12:12 am by K5CZ Reason: 1
I know, what are functions of the pins on the board, but I'm confused about how they are named in libraries and examples

For example:
UTFT(byte model, int RS, int WR,int CS, int RST, int SER=0);
means what?

RS - ?
WR - ?
CS - CS
RST - RESET
SER - ?

Edit: this was for paralel interface, for serial is syntax obvious:
UTFT(model,SERIAL_DATA_INPUT_MOSI,SERIAL_CLOCK_SCLK,CHIP_SELECT_CS,RESET, REGISTER_SELECT_DC);

K5CZ

#5
Nov 20, 2013, 06:43 pm Last Edit: Nov 20, 2013, 06:45 pm by K5CZ Reason: 1

Am I missing something ?


I use libraries and only modify PINS in the examples to test. So rest of code I do not post deliberately.
https://github.com/adafruit/Adafruit_ILI9340
http://www.seeedstudio.com/wiki/2.8%27%27_TFT_Touch_Shield_V2.0

I'll take some photographs and publish them.

raschemmel

That's fine but we need to know exactly which example you are running. Just telling us you're using
this or that library doesn't tell us which example you are trying to run with that library.
Also, you are forcing us to chase down libraries and examples which takes time.
What we need is the code for the example pasted in (or uploaded) and the library (uploaded)
That gives us everything we need , right here, right now.
Then a statement:
Tried to run "Hello World" from Seeed Studio (see attached)
Here's my definitions and photos.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

K5CZ

My latest attempt. I found ili9341 library on github for exactly same display. I investigate pin assignment for MEGA2560 and (may be wrong) here is:

Code: [Select]

{DDRE |= 0x08;PORTE &=~ 0x08;} //D5? CS
{DDRH |= 0x08;PORTH &=~ 0x08;} //D6? DC
{DDRH |= 0x10;PORTH &=~ 0x10;} //D7 backlight
{DDRD |= 0x10;PORTD &=~ 0x10;} //D4? RESET


My actual wiring is now:
SDO(MISO) - MISO
LED - D7
SCK - SCK
SDI(MOSI) - MOSI
D/C - D6
RESET - D4
CS - D5
GND - GND
VCC - +5V

Every example I run, serial monitor shows:
Code: [Select]
Read TFT ID failed, ID should be 0x09341, but read ID = 0x000
so it is obvious that the SPI communication is not working (only turning backlight on/off is working)

Attached ZIP file contains library and examples. I made no modifications.
The photo shows my bowl of spaghetti.

raschemmel

Ok , please bear with me . I need to ask you something just to make sure it is not the issue.
Exactly  how did you install the library?
Did you unzip it somewhere and copy it the library directory
or
did you unzip it DIRECTLY to the My Documents\Arduino\Libraries folder using the winzip explorer window?

Next, exactly how did you launch the program ?
Did you use Files\Open My Documents\Arduino\[library directory]\[filename] ?
or
did you use Sketch\add file\My Documents\Arduino\[library directory]\[filename] ?
or did you use Files\Examples\[select program using drop down mouse menus ?
then click on RUN =>
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

Read this:
http://arduino.cc/en/Guide/Libraries
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

K5CZ

Adding libraries and running examples is not problem. During test I have only one library in Arduino folder, because tested libraries may collide. I know about it and it is not my problem. Problem is SPI communication - or display may be faulty.

Trixi

So far everything looks OK (hardware, wiring and sketch) so it COULD be that the tft is damaged/didn't work

Did you see any feedback from the display, i.e. power led, bg light on or something like this ?
Dum spiro, spero - if you find my posting helpful, please click my Karma :)

K5CZ

Backlight is working. Setting D7 to high or low turns backlight on or off.  The display is a little more heated.

Although PCB contains a voltage regulator 5V -> 3V, I suspect that the 5V I/O data signals coming from Arduino the chip ILI9341 can not handle. The datasheet says:
ILI9341 can operate with 1.65V ~ 3.3V I/O interface voltage.

raschemmel

You might want to try one of these:
OKI-78SR-3.3/1.5-W36-C
4.95W 24Vin 3.3Vout
(That's P(W) = I(A)*V(V) =>  4.95W/3.3V=1.5A
available at Mouser:
Mouser P/N: 580-OKI78SR3.31.536C

http://www.mouser.com/ProductDetail/Murata/OKI-78SR-33-15-W36-C/?qs=%2fha2pyFadug1ZrXHkIky7LtoJCPWCweGXaSSyT98oJvt1QArCaucX9tJYw9tEMiA
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

MarkT

Firstly that chip is 3.3V logic only, DO NOT connect 5V signals to it or you may fry it.

The LED pin should not be connected directly to 3.3V, it needs about 30 ohms to 5V or about
5 ohms to 3.3V (its directly driving some white LEDs in parallel that need about 60mA)
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up