Author Topic: Working on NHD‐2.4‐240320SF‐CTXL#‐FTN1, have problem in initialization  (Read 3795 times)

sli25

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
    • View Profile
Hi,

I am working on NHD‐2.4‐240320SF‐CTXL#‐FTN1, and it doesn't show anything I want it to show.
I don't know the problem comes from the initialization or the display function.
I would like to ask how to tell this LED has been initialized successfully?

Thanks!

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Have you used our example code for your program?  The initialization there is good, as well as the write command/data routines.
See below:

Code: [Select]
//---------------------------------------------------------
/*
NHD_2_4_240320SF_CTXI_mega.ino
Program for writing to Newhaven Display 2.4 TFT with ILI9341 controller

(c)2013 Mike LaVine - Newhaven Display International, LLC.

        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
*/
//---------------------------------------------------------

// The 8 bit data bus is connected to PORTA of the Arduino Mega2560
// 5V voltage regulator on Arduino Mega has been replaced with a 3.3V regulator to provide 3.3V logic

int RS = 30;      // RS signal connected to Arduino digital pin 30
int WR = 31;      // /WR signal connected to Arduino digital pin 31
int RD = 32;      // /RD signal connected to Arduino digital pin 32
int RES = 33;     // /RES signal connected to Arduino digital pin 33

// /CS signal tied to GND
// IM0 signal tied to VDD

void comm_out(unsigned char c)
{
  digitalWrite(RS, LOW);
  PORTA = c;
  digitalWrite(WR, LOW);
  digitalWrite(WR, HIGH);
}

void data_out(unsigned char d)
{
  digitalWrite(RS, HIGH);
  PORTA = d;
  digitalWrite(WR, LOW);
  digitalWrite(WR, HIGH);
}
void disp()
{
unsigned int i;
comm_out(0x2C);              //command to begin writing to frame memory
for(i=0;i<38400;i++)         //fill screen with blue pixels
{
    data_out(0x00);
            data_out(0x1F);
            data_out(0x00);
            data_out(0x1F);
}
        for(i=0;i<38400;i++)         //fill screen with green pixels
{
    data_out(0x07);
            data_out(0xE0);
            data_out(0x07);
            data_out(0xE0);
        }
}

void setup()
{
  DDRC = 0xFF;   
  PORTC = 0x00;
  DDRA = 0xFF;
  PORTA = 0x00;
  digitalWrite(RD, HIGH);
  digitalWrite(WR, LOW);
  digitalWrite(RES, LOW);
  delay(250);
  digitalWrite(RES, HIGH);
  delay(250);
 
  comm_out(0x28);                                  //display off
  comm_out(0x11);  //exit SLEEP mode
 
  comm_out(0xCB);  //power control A
  data_out(0x39);
  data_out(0x2C);
  data_out(0x00);
  data_out(0x34);
  data_out(0x02);
 
  comm_out(0xCF);  //power control B
  data_out(0x00);
  data_out(0x81);
  data_out(0x30);
 
  comm_out(0xC0);
  data_out(0x26);  //power control 1
  data_out(0x04);  //second parameter for ILI9340 (ignored by ILI9341)
 
  comm_out(0xC1);
  data_out(0x11);                  //power control 2
 
  comm_out(0xC5);
  data_out(0x35);
  data_out(0x3E);  //VCOM control 1
 
  comm_out(0x36);
  data_out(0x88);                  //memory access control = BGR
 
  comm_out(0xB1);
  data_out(0x00);
  data_out(0x18);  //frame rate control
 
  comm_out(0xB6);
  data_out(0x0A);
  data_out(0xA2);  //display function control
 
  comm_out(0xC7);
  data_out(0xBE);                  //VCOM control 2
 
  comm_out(0x3A);
  data_out(0x55);                  //pixel format = 16 bit per pixel
 
  /*comm_out(0xE0);
  data_out(0x1F);                  //positive gamma correction
  data_out(0x1B);
  data_out(0x18);
  data_out(0x0B);
  data_out(0x0F);
  data_out(0x09);
  data_out(0x46);
  data_out(0xB5);
  data_out(0x37);
  data_out(0x0A);
  data_out(0x0C);
  data_out(0x07);
  data_out(0x07);
  data_out(0x05);
  data_out(0x00);
 
  comm_out(0xE1);
  data_out(0x00);                  //negative gamma correction
  data_out(0x24);
  data_out(0x27);
  data_out(0x04);
  data_out(0x10);
  data_out(0x06);
  data_out(0x39);
  data_out(0x74);
  data_out(0x48);
  data_out(0x05);
  data_out(0x13);
  data_out(0x38);
  data_out(0x38);
  data_out(0x3A);
  data_out(0x1F);*/
 
  comm_out(0xF2);                  //3g damma control
  data_out(0x02);                  //off
 
  comm_out(0x26);                  //gamma curve 3
  data_out(0x01);
 
  comm_out(0x2A);
  data_out(0x00);                  //column address set
  data_out(0x00);                  //start 0x0000
  data_out(0x00);
  data_out(0xEF);                  //end 0x00EF
 
  comm_out(0x2B);
  data_out(0x00);                  //page address set
  data_out(0x00);                  //start 0x0000
  data_out(0x01);
  data_out(0x3F);                  //end 0x003F
 
  comm_out(0x29);                  //display ON

  delay(10);
}

void loop()
{
  disp();
  delay(1000);
}

sli25

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
    • View Profile
Hi Michael,
Thanks for the reply.
I followed this sample code. However it doesn't work.
Do you have any more suggestions for it?

Thanks.

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
I'm sorry to hear you are having troubles getting the display to work, however I can assure you this code does work, as it has been confirmed with our testing, along with customers that have used it.  I can only assume the MCU you are using is not being configured correctly, or there is a timing issue.  Can you verify the communication and timing with an oscilloscope (timing specifications are given in the datasheet)?  Are you using 3.3V for both VDD and logic? Also, do you have any other displays to try on the off chance you have a defective unit?
« Last Edit: May 28, 2015, 03:02:04 PM by Michael_L »

sli25

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
    • View Profile
Hi Michael,
I have figured it out.
The reason I couldn't make it work was because the reset time for the WR signal is too short, which is 100ns. When I increased it into 1us, it works.
However, when I read the manual for reference, it says the minimum time for Write Control Pulse L Duration is 15ns. My previous code which didn't work definitely meet with this requirement. Did I misunderstand it?

Thanks!

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
The timing should be correct, as it is from the controller IC manufacturer's datasheet.  Have you confirmed this timing on a scope?

sli25

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
    • View Profile
Hi Michael,
Yes, I confirmed it from the Logical Analyzer on the oscilloscope.

 

Problem setting "function select c" register

Started by jonmon6691Board OLEDs

Replies: 3
Views: 2285
Last post May 04, 2016, 02:44:37 PM
by Saurabh_B
NHD-4.3-480800EF-CTXP#-T - HX8369 continious memory write problem

Started by Henning_SBoard TFTs

Replies: 3
Views: 3599
Last post September 17, 2014, 06:51:40 AM
by Henning_S
NHD-1.8-128160EF-CTXI# problem: becomes pale after using it for some time

Started by fvdhoefBoard TFTs

Replies: 1
Views: 2957
Last post July 31, 2014, 08:55:40 AM
by Michael_L
NHD-0420H1Z-FL-GBW-33V3 - 2 Lines Mode Problem

Started by gnyturanBoard Character LCDs

Replies: 6
Views: 3245
Last post October 29, 2015, 01:23:58 PM
by Saurabh_B
NHD-C0220BiZ-FSW-FBW-3V3M Problem -- Doesn't power on

Started by seilcompBoard Character LCDs

Replies: 6
Views: 3043
Last post December 10, 2015, 08:07:52 AM
by Paul_B