Go Down

Topic: mcufriend 2.8 inch TFT LCD display issues (Read 83161 times) previous topic - next topic

nanaicas

Dec 19, 2014, 09:20 pm Last Edit: Jan 20, 2015, 09:03 pm by nanaicas
Hello, everyone,

I have recently bought a couple of LCD TFT touchscreen shields from ebay:
2-8-Inch-TFT-LCD-Display-Touch-Screen-Module-with-SD-Solt-for-Arduino-UNO-TOP

This seemed to be a good choice (not too expensive) for a guy with no previous experience with lcd displays.

However (suprise?..), it seems that I can't get it work properly. Before posting here, I did some research and tried a few different libraries.

My setup

Hardware:




Software:


Unfortunately, all of them didn't work as expected. The majority of them showed white screen:


st7783 library seemed to at least be doing something:


After using an example "st7783->Mygraphicstest", the screen changed from white to "striped" (periodic display of white and dark lines), which seemed to be refreshing (perhaps responding to the commands from the example sketch). To confirm this, I removed all the commands in loop and setup, except from "tft.fillScreen(BLUE)". After this, at first the screen turned white, refreshed (blinked) and turned striped (and stayed that way, no more refreshing). Changing the filling color did absolutely nothing (at least visible to me), so even though the program is trying to do something, the lcd display chip doesn't interpret it right (?).

So I thought maybe you guys have any ideas what could be causing this (because from the posts I've read before, many people are using similar displays). Following the steps from other posts, I couldn't get it working (and never saw a problem like I have).

I'm trying to read the st7783 chip manual (believing the seller's website), but it's a lot of info to grasp for a beginner with LCDs. So maybe you could point me in a right direction (or maybe provide a solution?).

I believe the pinning is correct as I'm using a shield.

So...

  • Timing issues between arduino and lcd chip? How to solve it if that's the case? Or how to debug it?
  • Incorrect initialization of the lcd chip? How to check it?
  • Incorrect commands being sent (every second line filled, creating a striped pattern)?
  • Maybe the pins are actually incorrect, even though it's a shield?
  • Defective lcd? Tried both of them, but none works as expected
  • More ideas?


I believe you people have more experience with this kind of stuff and could help me (and possibly others with similar issues).

The code with which I get a non-refreshing striped screen (using st7783 library):

Code: [Select]
#define LCD_CS A3   
#define LCD_CD A2   
#define LCD_WR A1   
#define LCD_RD A0   
// you can also just connect RESET to the arduino RESET pin
#define LCD_RESET A4
//Duemilanove/Diecimila/UNO/etc ('168 and '328 chips) microcontoller:
// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF

#include "TFTLCD.h"

TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

void setup(void) {
  Serial.begin(9600);
  Serial.println("8 Bit LCD test!");

  uint16_t identifier = tft.readRegister(0x00);
  Serial.print("ID=");
  Serial.println(identifier, HEX);

  Serial.println("tft.initDisplay");
  tft.reset();
  delay(100); // ???
  tft.initDisplay();
 
  Serial.println("fillscreen");
  tft.fillScreen(BLUE);

}

void loop(void) {

}


The result displayed on serial port:
Code: [Select]
8 Bit LCD test!
ID=0
tft.initDisplay
fillscreen


I'm sorry if this seems an easy task for you guys (or maybe I've made an obvious mistake), but pardon the beginner his mistakes!

Thank you for your time!


UPDATE ON: 2015-01-20

Wasn't really able to catch up with these posts (exams, work and stuff), but this post got my tft working:

http://forum.arduino.cc/index.php?topic=292777.0

Not much time to go this through right now, but will surely find out what was missing in my code :)
Thank you!





gtnasser

Hello,

I have the same board and tried several libraries with no success. The Smoke and Wires mod library worked for me, see the post at http://www.smokeandwires.co.nz/blog/a-2-4-tft-touchscreen-shield-for-arduino/ for download links.

shadersrjj

I've been trying to get this board working also.

I have tried the smokeandwires library and it makes the screen flicker but nothing else.

I have also tried to bit bash the ID register but can't get a sensible values out of it.

Anyone got any ideas or get any further?

Thanks

shadersrjj

Just got it working  :)  :)  :)  :)  :)  :)  :)

I downloaded the adafruit LCD driver (https://github.com/adafruit/TFTLCD-Library) and graphics lib. Once installed I selected the graphicstest file from the examples. the only thing I the changed was to force it be a ILI9341 as follows:

Code: [Select]
  if(identifier == 0x9325) {
    Serial.println(F("Found ILI9325 LCD driver"));
  } else if(identifier == 0x9328) {
    Serial.println(F("Found ILI9328 LCD driver"));
  } else if(identifier == 0x7575) {
    Serial.println(F("Found HX8347G LCD driver"));
  } else if(identifier == 0x9341) {
    Serial.println(F("Found ILI9341 LCD driver"));
  } else if(identifier == 0x8357) {
    Serial.println(F("Found HX8357D LCD driver"));
  } else {
    Serial.print(F("Unknown LCD driver chip: "));
    Serial.println(identifier, HEX);
    identifier = 0x9341;
  }


NOTE: I also keep the #define USE_ADAFRUIT_SHIELD_PINOUT 1 commented out.

shadersrjj

The SD card reader also works (adafruit libraries).

However, the touch screen (adafruit libraries) is a bit poor at the moment it works if you change the pin allocations to:

Code: [Select]
// These are the pins for the shield!
#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 7   // can be a digital pin
#define XP 6   // can be a digital pin

shadersrjj

#5
Jan 09, 2015, 05:06 pm Last Edit: Jan 09, 2015, 05:08 pm by shadersrjj
Quick update - I have got the paint program to work completely now with the pin allocations above (albeit you do have to use a bit of force).

I did have to invert the coordinates for the X and Y on the touch points.

I'm not sure if the screen is flipped in either axis but this worked OK.


lukegm

#6
Jan 10, 2015, 02:47 am Last Edit: Jan 10, 2015, 03:07 am by lukegm
Hi shadersrjj,

Could you please post your code?

I've just spent a couple of days trying to get (what looks like exactly the same screen) working with no, zero, success  :smiley-mad:

I even sat down and wrote an entire interface from the data sheet (which based on your info, is the wrong one :( st7781), just to try and figure out what was happening. As so many of the libraries available are completely unfathomable, if you're new to this, as I am. :smiley-confuse:

It would be great, to definitely workout if it just been the wrong libs the wrong way, or if the shield/display is actually DOA (which I completely believed it was until I read your post).

Thanks in advance.

PS. Just tried following your instructions, without any joy. Looking at the flex connector, it doesn't seem well attached to the board, so I think I'll go over it with the soldering iron and hopefully...

I'm really starting to think, saving $10 on this display, was definitely not worth the complete hassle. Has anyone tried to get any info from the manufacturer? Their site is completely broken, none of the downloads work and neither they or the people that sold it to me are answering emails. Definitely false economy :-(

Cheers
Luke

shadersrjj

#7
Jan 10, 2015, 01:51 pm Last Edit: Jan 10, 2015, 01:53 pm by shadersrjj
I did have the same opinion that the screen didn't work. Unfortunately, I have my uno wired up to a 8x8 LED matrix at the moment and I can't check that the library I have here definitely work.

To get mine working all I did (eventually) was to download the ADAFruit libraries and loaded the graphicstest example. I then made the changes specified to force it to one of the controllers in the list.

Maybe you can post what you have and I'll check.

Did you try the touch screen or SDI stuff without the display on. The SDI worked first time and the touch screen worked using the mods to the pins and the ADAFruit library (before I got the screen to work).

BTW Unless you know what you are doing Don't go near the flexi with soldering iron.

jasonw749

Just got it working  :)  :)  :)  :)  :)  :)  :)

I downloaded the adafruit LCD driver (https://github.com/adafruit/TFTLCD-Library) and graphics lib. Once installed I selected the graphicstest file from the examples. the only thing I the changed was to force it be a ILI9341 as follows:

Code: [Select]
  if(identifier == 0x9325) {
    Serial.println(F("Found ILI9325 LCD driver"));
  } else if(identifier == 0x9328) {
    Serial.println(F("Found ILI9328 LCD driver"));
  } else if(identifier == 0x7575) {
    Serial.println(F("Found HX8347G LCD driver"));
  } else if(identifier == 0x9341) {
    Serial.println(F("Found ILI9341 LCD driver"));
  } else if(identifier == 0x8357) {
    Serial.println(F("Found HX8357D LCD driver"));
  } else {
    Serial.print(F("Unknown LCD driver chip: "));
    Serial.println(identifier, HEX);
    identifier = 0x9341;
  }


NOTE: I also keep the #define USE_ADAFRUIT_SHIELD_PINOUT 1 commented out.
Thanks a lot for this, it helped me get it up and running.

One problem I have is using this with my Mega. It works fine on my Uno, but my Mega prints the following:

Code: [Select]
Using Adafruit 2.8" TFT Breakout Board Pinout
Unknown LCD driver chip: 0


while my Uno prints:


Code: [Select]
Using Adafruit 2.8" TFT Breakout Board Pinout
Unknown LCD driver chip: 8080


the pin numbers are the same on the mega, any idea why this is happening?

shadersrjj

#9
Jan 11, 2015, 10:02 am Last Edit: Jan 11, 2015, 01:54 pm by shadersrjj
I don't know much about the mega but when I was trying different libraries they did seem to have different pin assignments so it may be worth a check against the schematics and where the shield connects.

I did write a program to "bit bash" the id register out assuming it was loctaed at 00h. However, I normally got C0C0h or 0000h. Looking at the datasheet for the ILI9341 the ID register appears to be at 04h or D3h so I may go back to see I can read it now. However, it is worth bearing in mind that the driver might just be a cheap clone.

shadersrjj

#10
Jan 11, 2015, 12:27 pm Last Edit: Jan 11, 2015, 01:54 pm by shadersrjj
I have managed to confirm the ID of the LCD driver for my Ebay, mcufriend.com touch screen. This was found by reading it from D3h and it confirmed this was an ILI9341 ICD driver chip. I have some code that bit bashes it out on an UNO board and displays it serially. I make no guarantee for it so only use it under your own risk but it may help try to find and read the ID of your board (e.g. your can change to specific register to read).

BTW it looks complicated but actually is just driving ports high and low one command at a time so you should be able to create a timing diagram for what's going on pretty quickly (which is the main reason I write this kind of code like this)

Code: [Select]
//
// ILI9341 ID Checker against data sheet http://www.adafruit.com/datasheets/ILI9341.pdf
// Ugly bit basher - R Jennings 11/11/14 (http://www.shaders.co.uk)
//
 #define CS A3   // Chip Select goes to Analog 3
 #define CD A2   // Command/Data goes to Analog 2
 #define WR A1   // LCD Write goes to Analog 1
 #define RD A0   // LCD Read goes to Analog 0
 #define RST A4  // Can alternately just connect to Arduino's reset pin
 #define D0 8    // DO
 #define D1 9    // D1
 #define D2 2    // D2
 #define D3 3    // D3
 #define D4 4    // D4
 #define D5 5    // D5
 #define D6 6    // D6
 #define D7 7    // D7

void setup(void) {
// Set up port directions and default states
  pinMode(CS, OUTPUT);  pinMode(CD, OUTPUT);  pinMode(WR, OUTPUT);  pinMode(RD, OUTPUT);  pinMode(RST, OUTPUT);
  digitalWrite(CS, 1); digitalWrite(CD, 1); digitalWrite(WR, 1); digitalWrite(RD, 1); digitalWrite(RST, 1);
  pinMode(D0, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT);
  pinMode(D4, OUTPUT); pinMode(D5, OUTPUT); pinMode(D6, OUTPUT); pinMode(D7, OUTPUT);

// This just drivers the serial monitor no screen activity 
  Serial.begin(9600);
  Serial.println("TFT LCD test - Read of the ID register");
//HW Reset
  digitalWrite(RST,0); delay(5);
  digitalWrite(RST,1); delay(500); 
// Read the ID Register, D3h
// Start by writing to the command register with the register to read
  digitalWrite(CD, 0);
  digitalWrite(CS, 0);
  digitalWrite(D0, 1); digitalWrite(D1, 1); digitalWrite(D2, 0); digitalWrite(D3, 0);  // 3 - Change for lower nibble as required
  digitalWrite(D4, 1); digitalWrite(D5, 0); digitalWrite(D6, 1); digitalWrite(D7, 1);  // D - Change for upper nibble as required
  digitalWrite(WR, 0); digitalWrite(WR, 1);
  digitalWrite(CS, 1);   
// Switch to reading   
  pinMode(D0, INPUT);    pinMode(D1, INPUT);    pinMode(D2, INPUT);    pinMode(D3, INPUT);
  pinMode(D4, INPUT);    pinMode(D5, INPUT);    pinMode(D6, INPUT);    pinMode(D7, INPUT);
  int x=0;
// Then read the four bytes and print to the serial port
// See section 8.3.23 page 233 for read sequence
// 1st Parameter - Dummy byte could be anything
  digitalWrite(CD, 1);
  digitalWrite(CS, 0);
  digitalWrite(RD, 0);
  x=0;
  digitalWrite(RD, 0);
  x|=digitalRead(D0);    x|=digitalRead(D1)<<1; x|=digitalRead(D2)<<2; x|=digitalRead(D3)<<3;
  x|=digitalRead(D4)<<4; x|=digitalRead(D5)<<5; x|=digitalRead(D6)<<6; x|=digitalRead(D7)<<7;
  Serial.print("Dummny Byte Read =        "); Serial.println(x, HEX);   
  digitalWrite(RD, 1);
 // 2nd Parameter should be 00h
  x=0;
  digitalWrite(RD, 0);
  x|=digitalRead(D0);    x|=digitalRead(D1)<<1; x|=digitalRead(D2)<<2; x|=digitalRead(D3)<<3;
  x|=digitalRead(D4)<<4; x|=digitalRead(D5)<<5; x|=digitalRead(D6)<<6; x|=digitalRead(D7)<<7;
  Serial.print("2nd Parameter Byte Read = "); Serial.println(x, HEX);   
  digitalWrite(RD, 1);
 // 3rd Parameter should be 93h   
  x=0;
  digitalWrite(RD, 0);
  x|=digitalRead(D0);    x|=digitalRead(D1)<<1;  x|=digitalRead(D2)<<2; x|=digitalRead(D3)<<3;
  x|=digitalRead(D4)<<4; x|=digitalRead(D5)<<5;  x|=digitalRead(D6)<<6; x|=digitalRead(D7)<<7;
  Serial.print("3rd Parameter Byte Read = "); Serial.println(x, HEX);   
  digitalWrite(RD, 1);
 // 4th Parameter should be 41h     
  x=0;
  digitalWrite(RD, 0);
  x|=digitalRead(D0);    x|=digitalRead(D1)<<1; x|=digitalRead(D2)<<2; x|=digitalRead(D3)<<3;
  x|=digitalRead(D4)<<4; x|=digitalRead(D5)<<5; x|=digitalRead(D6)<<6; x|=digitalRead(D7)<<7;
  Serial.print("4th Parameter Byte Read = "); Serial.println(x, HEX);   
  digitalWrite(RD, 1); 
}
//Nothing to do here
void loop(void) {
}

jasonw749

I have managed to confirm the ID of the LCD driver for my Ebay, mcufriend.com touch screen. This was found by reading it from D3h and it confirmed this was an ILI9341 ICD driver chip. I have some code that bit bashes it out on an UNO board and displays it serially. I make no guarantee for it so only use it under your own risk but it may help try to find and read the ID of your board (e.g. your can change to specific register to read).

BTW it looks complicated but actually is just driving ports high and low one command at a time so you should be able to create a timing diagram for what's going on pretty quickly (which is the main reason I write this kind of code like this)

Code: [Select]
//
// ILI9341 ID Checker against data sheet http://www.adafruit.com/datasheets/ILI9341.pdf
// Ugly bit basher - R Jennings 11/11/14 (http://www.shaders.co.uk)
//
 #define CS A3   // Chip Select goes to Analog 3
 #define CD A2   // Command/Data goes to Analog 2
 #define WR A1   // LCD Write goes to Analog 1
 #define RD A0   // LCD Read goes to Analog 0
 #define RST A4  // Can alternately just connect to Arduino's reset pin
 #define D0 8    // DO
 #define D1 9    // D1
 #define D2 2    // D2
 #define D3 3    // D3
 #define D4 4    // D4
 #define D5 5    // D5
 #define D6 6    // D6
 #define D7 7    // D7

void setup(void) {
// Set up port directions and default states
  pinMode(CS, OUTPUT);  pinMode(CD, OUTPUT);  pinMode(WR, OUTPUT);  pinMode(RD, OUTPUT);  pinMode(RST, OUTPUT);
  digitalWrite(CS, 1); digitalWrite(CD, 1); digitalWrite(WR, 1); digitalWrite(RD, 1); digitalWrite(RST, 1);
  pinMode(D0, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT);
  pinMode(D4, OUTPUT); pinMode(D5, OUTPUT); pinMode(D6, OUTPUT); pinMode(D7, OUTPUT);

// This just drivers the serial monitor no screen activity 
  Serial.begin(9600);
  Serial.println("TFT LCD test - Read of the ID register");
//HW Reset
  digitalWrite(RST,0); delay(5);
  digitalWrite(RST,1); delay(500); 
// Read the ID Register, D3h
// Start by writing to the command register with the register to read
  digitalWrite(CD, 0);
  digitalWrite(CS, 0);
  digitalWrite(D0, 1); digitalWrite(D1, 1); digitalWrite(D2, 0); digitalWrite(D3, 0);  // 3 - Change for lower nibble as required
  digitalWrite(D4, 1); digitalWrite(D5, 0); digitalWrite(D6, 1); digitalWrite(D7, 1);  // D - Change for upper nibble as required
  digitalWrite(WR, 0); digitalWrite(WR, 1);
  digitalWrite(CS, 1);   
// Switch to reading   
  pinMode(D0, INPUT);    pinMode(D1, INPUT);    pinMode(D2, INPUT);    pinMode(D3, INPUT);
  pinMode(D4, INPUT);    pinMode(D5, INPUT);    pinMode(D6, INPUT);    pinMode(D7, INPUT);
  int x=0;
// Then read the four bytes and print to the serial port
// See section 8.3.23 page 233 for read sequence
// 1st Parameter - Dummy byte could be anything
  digitalWrite(CD, 1);
  digitalWrite(CS, 0);
  digitalWrite(RD, 0);
  x=0;
  digitalWrite(RD, 0);
  x|=digitalRead(D0);    x|=digitalRead(D1)<<1; x|=digitalRead(D2)<<2; x|=digitalRead(D3)<<3;
  x|=digitalRead(D4)<<4; x|=digitalRead(D5)<<5; x|=digitalRead(D6)<<6; x|=digitalRead(D7)<<7;
  Serial.print("Dummny Byte Read =        "); Serial.println(x, HEX);   
  digitalWrite(RD, 1);
 // 2nd Parameter should be 00h
  x=0;
  digitalWrite(RD, 0);
  x|=digitalRead(D0);    x|=digitalRead(D1)<<1; x|=digitalRead(D2)<<2; x|=digitalRead(D3)<<3;
  x|=digitalRead(D4)<<4; x|=digitalRead(D5)<<5; x|=digitalRead(D6)<<6; x|=digitalRead(D7)<<7;
  Serial.print("2nd Parameter Byte Read = "); Serial.println(x, HEX);   
  digitalWrite(RD, 1);
 // 3rd Parameter should be 93h   
  x=0;
  digitalWrite(RD, 0);
  x|=digitalRead(D0);    x|=digitalRead(D1)<<1;  x|=digitalRead(D2)<<2; x|=digitalRead(D3)<<3;
  x|=digitalRead(D4)<<4; x|=digitalRead(D5)<<5;  x|=digitalRead(D6)<<6; x|=digitalRead(D7)<<7;
  Serial.print("3rd Parameter Byte Read = "); Serial.println(x, HEX);   
  digitalWrite(RD, 1);
 // 4th Parameter should be 41h     
  x=0;
  digitalWrite(RD, 0);
  x|=digitalRead(D0);    x|=digitalRead(D1)<<1; x|=digitalRead(D2)<<2; x|=digitalRead(D3)<<3;
  x|=digitalRead(D4)<<4; x|=digitalRead(D5)<<5; x|=digitalRead(D6)<<6; x|=digitalRead(D7)<<7;
  Serial.print("4th Parameter Byte Read = "); Serial.println(x, HEX);   
  digitalWrite(RD, 1); 
}
//Nothing to do here
void loop(void) {
}

The mega seems to be the same as the Uno in that respect.

The only reason i want to use the mega is that i'd like to add some sensors to the board, and read some data, sch as temperature etc, and display it on the board.

shadersrjj

Quote
The mega seems to be the same as the Uno in that respect.
So the mega reports an ILI9341 LCD driver but still doesn't work with the Adafruit library?

felixLU

#13
Jan 15, 2015, 09:25 pm Last Edit: Jan 15, 2015, 09:26 pm by Bobo
Hi guys,

I have the same display 2.8 from MCUfriend. I got it from DX.COM, also inserted in Mega, but without result. Still have a blank screen.
Based on previous informations here, it was done by Uno (also Duemilanove ?).
Please, give your used libraries (or links) to github.

Thanks for all your posts.

buhosoft

Probably you find the answer in this post:

http://forum.arduino.cc/index.php?topic=292777.0

Go Up