mcufriend 3.5 LCD TFT ILI9327 with Arduino atmega328P , Need help plz!

Hi,

I need help with an LCD TFT mcufriend, bought from Aliexpress (chines)

Seller send me datasheet of an ILI9327 he said it is a 16 bits.

The test code (touchscreendemoshield and rectangles) sent by seller work,

but it is all white when using UTFT library of Electronics - Henning Karlsen

I am using Bee 1.0.6 with arduino Atmega 328P.

I tried the UTFT_Demo_400x240 using

UTFT myGLCD(ITDB32WC,A5,A4,A3,A2);
UTFT myGLCD(ILI9327,A5,A4,A3,A2);

But I get nothing.

The only working code is

//   ic:ili9327  
#define LCD_RD   A0
#define LCD_WR   A1     
#define LCD_RS   A2        
#define LCD_CS   A3       
#define LCD_REST A4

void Lcd_Writ_Bus(char VH)
{
  unsigned char i,temp,data; 
  data=VH;
  for(i=8;i<=9;i++)
  {
    temp=(data&0x01);
    if(temp)
      digitalWrite(i,HIGH);
    else
      digitalWrite(i,LOW);
    data=data>>1;
  }	
  for(i=2;i<=7;i++)
  {
    temp=(data&0x01);
    if(temp)
      digitalWrite(i,HIGH);
    else
      digitalWrite(i,LOW);
    data=data>>1;
  }	 

  digitalWrite(LCD_WR,LOW);
  digitalWrite(LCD_WR,HIGH);
}


void Lcd_Write_Com(char VH)  
{   
  digitalWrite(LCD_RS,LOW);
  Lcd_Writ_Bus(VH);
}

void Lcd_Write_Data(char VH)
{
  digitalWrite(LCD_RS,HIGH);
  Lcd_Writ_Bus(VH);
}

void Lcd_Write_Com_Data(int com,int dat)
{
  Lcd_Write_Com(com);
  Lcd_Write_Data(dat);
}

void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
  Lcd_Write_Com(0x2a); // Set_column_address 4 parameters
  Lcd_Write_Data(x1>>8);
  Lcd_Write_Data(x1);
  Lcd_Write_Data(x2>>8);
  Lcd_Write_Data(x2);

  Lcd_Write_Com(0x2b); // Set_page_address 4 parameters
  Lcd_Write_Data(y1>>8);
  Lcd_Write_Data(y1);
  Lcd_Write_Data(y2>>8);
  Lcd_Write_Data(y2);

  Lcd_Write_Com(0x2c); // Write_memory_start								 
}

void Lcd_Init(void)
{
  digitalWrite(LCD_REST,HIGH);
  delay(5); 
  digitalWrite(LCD_REST,LOW);
  delay(15);
  digitalWrite(LCD_REST,HIGH);
  delay(15);

  digitalWrite(LCD_CS,HIGH);
  digitalWrite(LCD_WR,HIGH);
  digitalWrite(LCD_CS,LOW);  //CS

  Lcd_Write_Com(0xE9);
  Lcd_Write_Data(0x20);

  Lcd_Write_Com(0x11); //Exit Sleep
  delay(100);

  Lcd_Write_Com(0xD1);
  Lcd_Write_Data(0x00);
  Lcd_Write_Data(0x71);
  Lcd_Write_Data(0x19);

  Lcd_Write_Com(0xD0);
  Lcd_Write_Data(0x07);
  Lcd_Write_Data(0x01);
  Lcd_Write_Data(0x08);

  Lcd_Write_Com(0x36);
  Lcd_Write_Data(0x48);

  Lcd_Write_Com(0x3A);
  Lcd_Write_Data(0x05);

  Lcd_Write_Com(0xC1);
  Lcd_Write_Data(0x10);
  Lcd_Write_Data(0x10);
  Lcd_Write_Data(0x02);
  Lcd_Write_Data(0x02);

  Lcd_Write_Com(0xC0); //Set Default Gamma
  Lcd_Write_Data(0x00);
  Lcd_Write_Data(0x35);
  Lcd_Write_Data(0x00);
  Lcd_Write_Data(0x00);
  Lcd_Write_Data(0x01);
  Lcd_Write_Data(0x02);

  Lcd_Write_Com(0xC5); //Set frame rate
  Lcd_Write_Data(0x04);

  Lcd_Write_Com(0xD2); //power setting
  Lcd_Write_Data(0x01);
  Lcd_Write_Data(0x44);

  Lcd_Write_Com(0xC8); //Set Gamma
  Lcd_Write_Data(0x04);
  Lcd_Write_Data(0x67);
  Lcd_Write_Data(0x35);
  Lcd_Write_Data(0x04);
  Lcd_Write_Data(0x08);
  Lcd_Write_Data(0x06);
  Lcd_Write_Data(0x24);
  Lcd_Write_Data(0x01);
  Lcd_Write_Data(0x37);
  Lcd_Write_Data(0x40);
  Lcd_Write_Data(0x03);
  Lcd_Write_Data(0x10);
  Lcd_Write_Data(0x08);
  Lcd_Write_Data(0x80);
  Lcd_Write_Data(0x00);

  Lcd_Write_Com(0x2A); 
  Lcd_Write_Data(0x00);
  Lcd_Write_Data(0x00);
  Lcd_Write_Data(0x00);
  Lcd_Write_Data(0xeF);

  Lcd_Write_Com(0x2B); 
  Lcd_Write_Data(0x00);
  Lcd_Write_Data(0x00);
  Lcd_Write_Data(0x01);
  //  Lcd_Write_Data(0x3F);
  Lcd_Write_Data(0x8F); // on internet

  Lcd_Write_Com(0x29); //display on      

  Lcd_Write_Com(0x2C); //display on 

  digitalWrite(LCD_CS,HIGH);
}

void H_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)                   
{	
  unsigned int i,j;
  Lcd_Write_Com(0x02c); //write_memory_start
  digitalWrite(LCD_RS,HIGH);
  digitalWrite(LCD_CS,LOW);
  l=l+x;
  Address_set(x,y,l,y);
  j=l*2;
  for(i=1;i<=j;i++)
  {
    Lcd_Write_Data(c);
  }
  digitalWrite(LCD_CS,HIGH);   
}

void V_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)                   
{	
  unsigned int i,j;
  Lcd_Write_Com(0x02c); //write_memory_start
  digitalWrite(LCD_RS,HIGH);
  digitalWrite(LCD_CS,LOW);
  l=l+y;
  Address_set(x,y,x,l);
  j=l*2;
  for(i=1;i<=j;i++)
  {
    Lcd_Write_Data(c);
  }
  digitalWrite(LCD_CS,HIGH);   
}

void Rect(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c)
{
  H_line(x  , y  , w, c);
  H_line(x  , y+h, w, c);
  V_line(x  , y  , h, c);
  V_line(x+w, y  , h, c);
}

void Rectf(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c)
{
  unsigned int i;
  for(i=0;i<h;i++)
  {
    H_line(x  , y  , w, c);
    H_line(x  , y+i, w, c);
  }
}

void LCD_Clear(unsigned int j)                   
{	
  unsigned int i,m;
  Lcd_Write_Com(0x02c); //write_memory_start
  digitalWrite(LCD_RS,HIGH);
  digitalWrite(LCD_CS,LOW);
  Address_set(0,0,479,399);

  for(i=0;i<480;i++)
    for(m=0;m<400;m++)
    {
      Lcd_Write_Data(j);
    }
  digitalWrite(LCD_CS,HIGH);   
}

void setup()
{
  for(int p=2;p<10;p++)
  {
    pinMode(p,OUTPUT);
  }
  pinMode(A0,OUTPUT);
  pinMode(A1,OUTPUT);
  pinMode(A2,OUTPUT);
  pinMode(A3,OUTPUT);
  pinMode(A4,OUTPUT);
  digitalWrite(A0, HIGH);
  digitalWrite(A1, HIGH);
  digitalWrite(A2, HIGH);
  digitalWrite(A3, HIGH);
  digitalWrite(A4, HIGH);
  Lcd_Init();
  LCD_Clear(0x00);
}

void loop()
{  

  for(int i=0;i<1000;i++)
  {
    Rect(random(300),random(300),random(300),random(300),random(65535)); // rectangle at x, y, with, hight, color
  }
  LCD_Clear(0x00);
}

Is it possible that is not an 9327?

Anyone can help please?

Hi All,

I make it working, to help all other people using such LCD TFT screen with Arduino UNO R3, I used

UTFT myGLCD(ILI9327_8,A2,A1,A3,A4);

This screen look to be an 8 bits

hi'

UTFT myGLCD(ILI9327_8,A2,A1,A3,A4);

ILI9327_8 don't exist in original library, it's hack from Source.
Where did you find this library ? (here ?? UTFT/tft_drivers/ili9327_8 at master · dgolda/UTFT · GitHub )

This full hack library won't work with my LCD 3,5'' Arduino uno shield.
Behind screen, no label on pin, so I don't know how to do.

Thx

Hi.

There is an important note at Electronics - Henning Karlsen

Important:

Due to the size of the library I do not recommend using it on ATmega328 (Arduino 2009/Uno) and ATmega32U4 (Arduino Leonardo) as they only have 32KB of flash memory.

It will work, but you will be severely limited in available flash memory for your application.

Consider it. May be you are overloading the chipset.

Also, could you provide me the libraries to make the test code (touchscreendemoshield and rectangles) running. I do not find the libraries. "rectangles.ino" do not require a library, but "touchscreendemoshield" yes. So, please, do help me. I do not want the UTFT libraries, but those with the test code.

JavierDdD
javierddd@droidduino.com
www.droidduino.com

https://docviewer.yandex.com/?url=ya-disk-public%3A%2F%2FhbmHnWtmnDn0QfGH0RLFwQVWZGv9RiOyFhFSVFkQrgE%3D&name=UNO%20ili9327%208bit.rar&c=550ded5d0fa7

with test tft and touch.

but el touch is reves mode

Hello,
Could somebody test GitHub - dgolda/UTFT: Modified UTFT library working with ILI9327 8-bit for example 3.5" TFT LCD from mcufriend.com with ILI9327 8bit display for UNO?
I've just added some fixes and code compiles for UNO and works with my display for MEGA.
But I haven't display for UNO, so I cannot test if it works.

My display works with init code:
UTFT myGLCD(NIC35WS,A2,A1,A3,A4); //3.5" TFTLCD for arduino 2560 from mcufriend.com on UNO

Maybe version for UNO needs also A0 for LCD_RD, but I'm not sure...

I have just received a "similar" UNO shield from AliExpress.
http://www.aliexpress.com/item/1pc-3-6-inch-3-6-TFT-LCD-Shield-Touch-Panel-Display-with-TF-Reader-for/1814791861.html

The unit that I received has actually got a slightly different pcb. Same major components - different routes for traces. It contains a R61509V controller (ID = 0xB509) instead of an ILI9327 (ID = 0x9327).
The pcb says "www.mcufriend.com 3.6 inch tftlcd for arduino UNO"

I have attempted to add "R61509V_8" support to UTFT with no success. The White screen does not even flicker !!!

Has anyone had any success with running this display? Or any 400x240 display with a R61509V in 8-bit parallel?

The Resistive touch screen does not behave as expected. (e.g. just reporting to Serial )

At the same time, I ordered an ILI9488 display: http://www.aliexpress.com/item/1pcs-3-95-inch-LCD-Display-Module-TFT-LCD-screen-for-Arduino-UNO-R3-Board/32412273145.html
The pcb says "www.mcufriend.com 3.95" TFT LCD for arduino uno"

I did succeed in adding "ILI9488_8" support to UTFT. This runs ok. The Resistive Touchscreen works perfectly.

David.

Try CTE40 as your LCD model as it might work for you as it does for me.

From my so far short experience with common UTFT library:
Check your TFT LCD "model" and its data bus specification ( serial , 8 bit, 16 bits) than verify that your control signals ( WR, RS,CS, RST ) pins are the one actually in use in your setup. .
Go by connections, not by shield or model specification.
Than verify data bus connections / pins assignment you are actually using.
These appear to be "hardcoded " - for Uno - by various vendors shield hardware - not selectable by any other visible means. ( Working on that one)
If your backlight is connected to VCC , not a pin, it will come on as soon as power is applied, it has nothing to do with the rest of the TFT LCD I/O pins assignments.

The UTFT class has no feedback as far as initialization goes, I have not gotten the "fillScreen" to work , not yet. Trying to figure out how to assign data pins the way I selected them.

And that appears to be the first and only function to verify that the controls and data bus are actually working. Text and graphic should than work too.
Same should apply to any similar TFT code, they seems to be all originating from same source anyway.

@HazardsMind,

I posted a link to the specific UNO shield. And identified the specific controller (R61509V).
So I can't see how any driver written for an ILI9486 (16-bit) could work with a UNO.

The UNO does not have enough GPIO pins. The R61509V has completely different register addresses.

@Vaclav,

The pins are clearly marked on the pcb. They must be correct because I managed to read the ID register to identify that it was R61509V and not an ILI9327. The Read operation involved every control pin and data bus pin.

David.

david_prentice:
@HazardsMind,

I posted a link to the specific UNO shield. And identified the specific controller (R61509V).
So I can't see how any driver written for an ILI9486 (16-bit) could work with a UNO.

The UNO does not have enough GPIO pins. The R61509V has completely different register addresses.

@Vaclav,

The pins are clearly marked on the pcb. They must be correct because I managed to read the ID register to identify that it was R61509V and not an ILI9327. The Read operation involved every control pin and data bus pin.

David.

Great - so what is the problem?
Can you do "fillScreen" of any color?
I believe R in high and W is low - so "floating "R/W would , in theory work in read mode and not necessarily in write mode.

That would be my next step.

@david_prentice: How did you get the touch on the 3.95" ILI9488 screen to work? You can get technical on me, I don't mind :slight_smile:

Thanks,

Peter

It is a resistive touchscreen. Use the <Touchscreen.h> library from Adafruit. Likewise, earlier in this thread there is a modified Adafruit_TFTLCD.h library that supports the ILI9327 and ILI9488.

You should be able to use the examples from the Touchscreen library. Or the example "tftpaint2.ino" from diger67's modified "Adafruit_TFTLCD.h" library.

TouchScreen ts = TouchScreen(6, A1, A2, 7, 300);   // for mcufriend shield

Incidentally, the fillTriangle() method goes wrong with the larger screens. Edit the Adafruit_GFX.cpp file to use int32_t for sa, sb

I have now got the UTFT library to support ILI9488 and R65109V on the 8-bit bus used by the Uno shields.
My R65109 Problem was that UTFT assumes 8-bit commands. The Renesas controllers use registers like 0x200, 0x400, 0x600, ...
I just had to change the argument type for LCD_Write_COM() family of methods.

Note that UTFT does not understand the /RD pin on controllers. Make sure that you make the A0 pin ouput high before any UTFT example will work.
Note that <UTouch.h> library expects an intelligent controller. The mcufriend Uno shields do not have a touch controller.

I will also measure the pins on my 240x400 shield to see what the touch problem is.

David.

Edit. added constructor()

David,

The 3.95" ILI9488 screen doesn't have pins for the touchscreen just a flex connector. How did you hook that up to the Arduino? Did you use add a touch controller?

Thanks,

Peter

I had assumed that you were using the mcufriend shield. If you are using a bare module, you must run the Arduino at 3.3V. TFT controllers are always 3.3V (or less).

As long as you supply 3.3V to the VCC pin on the controller, you can probably get away with series resistors to the data and control pins. I advise you to just run the AVR at 3.3V. That is a lot easier than resistors or level-shifting buffer chips.

If you want to run the same example code as Shield owners, wire your 4 touchscreen wires to pins: 6, 7, A1, A2 on the Arduino.

David.

It looks like we're talking about different boards - sorry. I was referring to this comment you made:

At the same time, I ordered an ILI9488 display: http://www.aliexpress.com/item/1pcs-3-95-inch-LCD-Display-Module-TFT-LCD-screen-for-Arduino-UNO-R3-Board/32412273145.html
The pcb says "www.mcufriend.com 3.95" TFT LCD for arduino uno"

I did succeed in adding "ILI9488_8" support to UTFT. This runs ok. The Resistive Touchscreen works perfectly.

It looks like it has a 9 or 10-pin flex cable connector for the touchscreen. Your comment above makes it sounds like you were able to get the touchscreen to work. How did you connect this 9/10-pin flex cable to Arduino?

On the shield, D6, D7, A1 and A2 are marked LCD_D6, LCD_D7, LCD_WR and LCD_RS. Are you saying these pins are used for both the TFT display and the touchscreen?

Thanks,

Peter

My bad! I took my shield apart to better understand how it is wired. The 9/10 pin flex cable that I thought was for the touchscreen is actually the LED backlight connector.

I'm not able to see exactly where the 4-pin touchscreen flex cable goes, but I did see connections from it to pins D6 and D7 - so most likely what David wrote is correct. I'll have to try this out later today.

Thanks for the help David!

Peter

Yes, these mcufriend Shields are very convenient for a Uno. However, you only have A5 available for the outside world.

Mind you, the microSD can supply an infinite amount of pictures / data. The TouchScreen allows you some User Input. The TFT can display your pictures / data attractively.

The Touch wires are shared with the regular TFT connections.

The alternative would be for an external Touch controller on the SPI bus with the microSD. This could use A5 as its /CS pin. But you would not have anywhere for a Touch_IRQ pin on a UNO. (Actually, I have an ILI9325 + ADS7946 screen which makes use of A6 pin on a Seeeduino)

David.

David was correct. D6, D7, A1 and A2 are shared between the LCD display and the touchscreen.

Thanks! :slight_smile:

david_prentice:
It is a resistive touchscreen. Use the <Touchscreen.h> library from Adafruit. Likewise, earlier in this thread there is a modified Adafruit_TFTLCD.h library that supports the ILI9327 and ILI9488.

You should be able to use the examples from the Touchscreen library. Or the example "tftpaint2.ino" from diger67's modified "Adafruit_TFTLCD.h" library.

TouchScreen ts = TouchScreen(6, A1, A2, 7, 300);   // for mcufriend shield

Incidentally, the fillTriangle() method goes wrong with the larger screens. Edit the Adafruit_GFX.cpp file to use int32_t for sa, sb

I have now got the UTFT library to support ILI9488 and R65109V on the 8-bit bus used by the Uno shields.
My R65109 Problem was that UTFT assumes 8-bit commands. The Renesas controllers use registers like 0x200, 0x400, 0x600, ...
I just had to change the argument type for LCD_Write_COM() family of methods.

Note that UTFT does not understand the /RD pin on controllers. Make sure that you make the A0 pin ouput high before any UTFT example will work.
Note that <UTouch.h> library expects an intelligent controller. The mcufriend Uno shields do not have a touch controller.

I will also measure the pins on my 240x400 shield to see what the touch problem is.

David.

Edit. added constructor()

David can you please share the library and code for R61509 tft driver.