Go Down

Topic: 2.8'' TFT LCD Touch Module Arduino UNO connection (Read 89 times) previous topic - next topic

YiChuan

May 03, 2016, 05:18 am Last Edit: May 03, 2016, 09:05 am by YiChuan Reason: Attachments
Hi,

I have bought a 2.8'' TFT LCD Touch Model recently. Somehow the screen only displays a white screen even if a sample code is compiled and uploaded.

I have already searched through this forum but I found out most of the 2.8'' TFT LCD problems discussed here are based on the one with a breakout board module, which can be directly plugged into Arduino UNO. While the screen I got has 34 pins, 17x2.

The seller provides this link:

https://www.itead.cc/blog/itdb02-2-4-display-with-arduino

as a guide to interface the screen with Arduino UNO. I find out that the screen shown in the link actually has slightly different pins compare to the one I bought (Because the one is for 2.4'' TFT LCD I guess?).

My screen: http://imgur.com/QItnyTE


However, I still follow the connection on the link which I connect:

DB0-DB16 to pin D0-D13 , pin A0-A1 (I assumed this is a typo because the pins are only up to DB15)
RESET to A2
CS to A3
WR to A4
RS to A5

LCD-A to 3.3V , VCC to 5V , GND to GND
*Notice that my screen does not has the pin LCD-A, again, I assumed that pin BL (the pin above DB15) is LCD-A

And the sample code I used:

Code: [Select]
#define LCD_RS 19
#define LCD_REST 16
#define LCD_WR 18
#define LCD_CS 17

void main_Write_COM(int DH)
{
unsigned char i;
int temp;
digitalWrite(LCD_RS,LOW);
digitalWrite(LCD_CS,LOW);
for(i=0;i<16;i++)
{
 temp=(DH&0x01);
 if(temp)
   digitalWrite(i,HIGH);
 else
   digitalWrite(i,LOW);
 DH=DH>>1;
}
digitalWrite(LCD_WR,LOW);
digitalWrite(LCD_WR,HIGH);
digitalWrite(LCD_CS,HIGH);
}

void main_Write_DATA(int DH)
{
unsigned char i;
int temp;
digitalWrite(LCD_RS,HIGH);
digitalWrite(LCD_CS,LOW);
for(i=0;i<16;i++)
{
 temp=(DH&0x01);
 if(temp)
   digitalWrite(i,HIGH);
 else
   digitalWrite(i,LOW);
 DH=DH>>1;
}
digitalWrite(LCD_WR,LOW);
digitalWrite(LCD_WR,HIGH);
digitalWrite(LCD_CS,HIGH);
}

void main_W_com_data(int com1,int dat1)
{
main_Write_COM(com1);
main_Write_DATA(dat1);
}

void address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
main_W_com_data(0x0002,x1>>8 );     // Column address start2
main_W_com_data(0x0003,x1);    // Column address start1
main_W_com_data(0x0004,x2>>8 );     // Column address end2
main_W_com_data(0x0005,x2);    // Column address end1
main_W_com_data(0x0006,y1>>8 );     // Row address start2
main_W_com_data(0x0007,y1);    // Row address start1
main_W_com_data(0x0008,y2>>8 );     // Row address end2
main_W_com_data(0x0009,y2);    // Row address end1
main_Write_COM(0x0022);      

}

void main_init(void)
{

digitalWrite(LCD_REST,HIGH);
delay(5);
digitalWrite(LCD_REST,LOW);
delay(10);
digitalWrite(LCD_REST,HIGH);
delay(20);

//  VENDOR
main_W_com_data(0x0046,0x00A4);
main_W_com_data(0x0047,0x0053);
main_W_com_data(0x0048,0x0000);
main_W_com_data(0x0049,0x0044);
main_W_com_data(0x004a,0x0004);
main_W_com_data(0x004b,0x0067);
main_W_com_data(0x004c,0x0033);
main_W_com_data(0x004d,0x0077);
main_W_com_data(0x004e,0x0012);
main_W_com_data(0x004f,0x004C);
main_W_com_data(0x0050,0x0046);
main_W_com_data(0x0051,0x0044);

//240x320 window setting
main_W_com_data(0x0002,0x0000); // Column address start2
main_W_com_data(0x0003,0x0000); // Column address start1
main_W_com_data(0x0004,0x0000); // Column address end2
main_W_com_data(0x0005,0x00ef); // Column address end1
main_W_com_data(0x0006,0x0000); // Row address start2
main_W_com_data(0x0007,0x0000); // Row address start1
main_W_com_data(0x0008,0x0001); // Row address end2
main_W_com_data(0x0009,0x003f); // Row address end1

// Display Setting
main_W_com_data(0x0001,0x0006); // IDMON=0, INVON=1, NORON=1, PTLON=0
main_W_com_data(0x0016,0x00C8); // MY=0, MX=0, MV=0, ML=1, BGR=0, TEON=0   0048
main_W_com_data(0x0023,0x0095); // N_DC=1001 0101
main_W_com_data(0x0024,0x0095); // PI_DC=1001 0101
main_W_com_data(0x0025,0x00FF); // I_DC=1111 1111

main_W_com_data(0x0027,0x0002); // N_BP=0000 0010
main_W_com_data(0x0028,0x0002); // N_FP=0000 0010
main_W_com_data(0x0029,0x0002); // PI_BP=0000 0010
main_W_com_data(0x002a,0x0002); // PI_FP=0000 0010
main_W_com_data(0x002C,0x0002); // I_BP=0000 0010
main_W_com_data(0x002d,0x0002); // I_FP=0000 0010

main_W_com_data(0x003a,0x0001); // N_RTN=0000, N_NW=001    0001
main_W_com_data(0x003b,0x0000); // P_RTN=0000, P_NW=001
main_W_com_data(0x003c,0x00f0); // I_RTN=1111, I_NW=000
main_W_com_data(0x003d,0x0000); // DIV=00
delay(1);
main_W_com_data(0x0035,0x0038); // EQS=38h
main_W_com_data(0x0036,0x0078); // EQP=78h
main_W_com_data(0x003E,0x0038); // SON=38h
main_W_com_data(0x0040,0x000F); // GDON=0Fh
main_W_com_data(0x0041,0x00F0); // GDOFF

// Power Supply Setting
main_W_com_data(0x0019,0x0049); // CADJ=0100, CUADJ=100, OSD_EN=1 ,60Hz
main_W_com_data(0x0093,0x000F); // RADJ=1111, 100%
delay(1);
main_W_com_data(0x0020,0x0040); // BT=0100
main_W_com_data(0x001D,0x0007); // VC1=111   0007
main_W_com_data(0x001E,0x0000); // VC3=000
main_W_com_data(0x001F,0x0004); // VRH=0011

//VCOM SETTING
main_W_com_data(0x0044,0x004D); // VCM=101 0000  4D
main_W_com_data(0x0045,0x000E); // VDV=1 0001   0011
delay(1);
main_W_com_data(0x001C,0x0004); // AP=100
delay(2);

main_W_com_data(0x001B,0x0018); // GASENB=0, PON=0, DK=1, XDK=0, VLCD_TRI=0, STB=0
delay(1);
main_W_com_data(0x001B,0x0010); // GASENB=0, PON=1, DK=0, XDK=0, VLCD_TRI=0, STB=0
delay(1);
main_W_com_data(0x0043,0x0080); //set VCOMG=1
delay(2);

// Display ON Setting
main_W_com_data(0x0090,0x007F); // SAP=0111 1111
main_W_com_data(0x0026,0x0004); //GON=0, DTE=0, D=01
delay(1);
main_W_com_data(0x0026,0x0024); //GON=1, DTE=0, D=01
main_W_com_data(0x0026,0x002C); //GON=1, DTE=0, D=11
delay(1);
main_W_com_data(0x0026,0x003C); //GON=1, DTE=1, D=11

// INTERNAL REGISTER SETTING
main_W_com_data(0x0057,0x0002); // TEST_Mode=1: into TEST mode
main_W_com_data(0x0095,0x0001); // SET DISPLAY CLOCK AND PUMPING CLOCK TO SYNCHRONIZE
main_W_com_data(0x0057,0x0000); // TEST_Mode=0: exit TEST mode
//main_W_com_data(0x0021,0x0000);
main_Write_COM(0x0022);  

}

void Pant(unsigned int color)
{
int i,j;
address_set(0,0,239,319);

for(i=0;i<320;i++)
{
 for (j=0;j<240;j++)
 {
   main_Write_DATA(color);
 }

}
}

void setup()
{
unsigned char p;
for(p=0;p<20;p++)
{
 pinMode(p,OUTPUT);
}
main_init();
}

void loop()

Pant(0xf800); //Red
delay(1000);
Pant(0X07E0); //Green
delay(1000);
Pant(0x001f); //Blue
delay(1000);
}


And the result I got, WHITE SCREEN.
So, anyone has deal with this kind of 2.8'' touch screen before? What is the exact connection on this? And also on my screen, the pins MISO, MOSI, CLK, T_CS, PEN, F_CS are left unconnected.

Really appreciate for any helps, thanks!

TommiP

Hi

First, please use code-tags with your first post.

Have you tried to match these pins definitions ? I mean that you have connected for example RESET to the pin A2 but defined it to pin 16 in your demo code..

RESET to A2
CS to A3
WR to A4
RS to A5

...


And the sample code I used:

#define LCD_RS 19
#define LCD_REST 16
#define LCD_WR 18
#define LCD_CS 17
TommiP

YiChuan

Hi TommiP,

Thanks for the kind reply.
Isn't it the pins are suppose to be declared like this?

A0 = Pin 14
A1 = Pin 15
A2 = Pin 16
A3 = Pin 17
A4 = Pin 18
A5 = Pin 19

since digital pin 13 = Pin 13
Do correct me if I am wrong, thanks.



But what really confused me is the rest of the pin connection. Am I suppose to let MISO and MOSI pins unconnected? And the four pins on top I supposed they are for touch screen features so it is fine to let it unused since my code doesn't need that.

By the way, here is another sample code I used to test.
Code: [Select]
#include <UTFT.h>

extern uint8_t SmallFont[];


UTFT myGLCD(ITDB28,A5,A4,A3,A2);

void setup()
{
  randomSeed(analogRead(0));
 
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
}

void loop()
{
  int buf[318];
  int x, x2;
  int y, y2;
  int r;

  myGLCD.clrScr();


  myGLCD.setColor(0, 0, 255);
  myGLCD.drawRect(0, 14, 319, 225);

// Draw some filled rectangles
  for (int i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
        myGLCD.setColor(255,0,255);
        break;
      case 2:         
        myGLCD.setColor(255,0,0);
        break;
      case 3:
        myGLCD.setColor(0,255,0);
        break;
      case 4:
        myGLCD.setColor(0,0,255);
        break;
      case 5:
        myGLCD.setColor(255,255,0);
        break;
    }
    myGLCD.fillRect(70+(i*20), 30+(i*20), 130+(i*20), 90+(i*20));
  }

  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);
 
  delay (10000);
}


The code can be compiled and uploaded, and the result is still white screen.
I have also tried supplying a 3.3V logic instead of 5V to the board and it is the same. (I experienced the same situation before when handling a 2.2'' TFT LCD without touch panel, it is said that some screen works only in a condition of 3.3V logic)

So if anyone has handled this kind of LCD before and successfully display something on it with Arduino UNO, a little help will be very much appreciated!



TommiP

A0 = Pin 14
A1 = Pin 15
A2 = Pin 16
A3 = Pin 17
A4 = Pin 18
A5 = Pin 19
No, you were right. I was confused 'cos I'm used to use 'A0' instead of '14'  :)
 

Am I suppose to let MISO and MOSI pins unconnected?
I think not. Also pins 11-13 on Uno are SCK, MOSI and MISO and you had those connected already as I/O, right? I'm pretty sure that if you'll use those pins via ICSP port as SPI bus, you can't use pins D11-D13 as I/O pins.

Anyway, 'cos there aren't multiple MOSI, MISO, or SCK pins, I think that SPI pins for touch and tft are same on tft board and user has to choose which one by T_CS and CS pins. If so, you have to connect Uno to the tft boards MOSI, MISO and CLK pins.

What might be the F_CS pin ? Is there third SPI device on tft board, maybe sd card reader ?


And the four pins on top I supposed they are for touch screen features
I think that CLK pins is common for all SPI devices on tft board. I don't recognize pin 'PEN'.



TommiP


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy