Author Topic: NHD-2.4-240320CF-CTXI#-F Display Not Responding  (Read 59 times)

sjdorsay

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
NHD-2.4-240320CF-CTXI#-F Display Not Responding
« on: October 11, 2018, 08:40:10 PM »
I am attempting to interface this display with an Arduino as a practice run before I move further into my design. I found this post earlier

https://www.newhavendisplay.com/NHD_forum/index.php/topic,1763.msg3491.html#msg3491

which has very helpful code. But when I follow the setup described in the files and upload the sketch to my arduino the display just dims a bit.

When I use the example code provided in the Application Notes section there is no visible change. What reasons might be causing this issue?

sjdorsay

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: NHD-2.4-240320CF-CTXI#-F Display Not Responding
« Reply #1 on: October 17, 2018, 07:29:23 PM »
When I run the attached code on my display module the display turns off then on which is expected as I send the display off command then the display on command during initialization. After that I attempt to change the screen to a solid colour but there is no change in colour. Maybe there is something wrong with my code. Could someone please review it? It is for the Arduino Uno Rev 3.

I have also attached a PDF of my schematic in case anyone wants to see if I made a mistake in hardware

Code: [Select]
/*
 * HW RESET DEFAULT:
 * o 18 bpp
 * o Sleep
 *
 * CONTROL LINES:
 * nCS  - NA, tied to ground
 * nRES - A3
 * DC   - A2
 * nWR  - A1
 * nRD  - A0
 *
 * DATA LINES:
 * D[1:0] - D9:D8
 * D[7:2] - D7:D2
 */

int nRS = A3;   // Active low reset
int DC = A2;    // Data/Command
int nWR = A1;   // Active low write
int nRD = A0;   // Active low read

// 18bpp or 16bpp
#define MODE_18BPP

#ifdef MODE_18BPP
/* 8080-II 8-bit 18 bpp format
 * (0brrrr_rggg_ggbb_bbbx)
 * x: LSB of all colours
 */
#define RED     (0xF800)
#define GREEN   (0x07C0)
#define BLUE    (0x003E)

#else
/* 8080-II 8-bit 16 bpp format
 * (0brrrr_rggg_gggb_bbbb)
 */
#define RED     (0xF800)
#define GREEN   (0x07E0)
#define BLUE    (0x001F)

#endif

void TFT_SEND_CMD(uint8_t cmd) {
  PORTC |= 0x09; // Set nWR and DC pins low

  PORTB &= (0x03 & cmd);
  PORTD &= (0xFC & cmd);

  delayMicroseconds(1);
  PORTC |= 0x0B; // Set nWR pins high
  delayMicroseconds(1);
  PORTC |= 0x0F; // Set DC pin high
}

void TFT_SEND_DATA(uint8_t dat) {
  PORTC |= 0x0D; // Set nWR pin low

  PORTB &= (0x03 & dat);
  PORTD &= (0xFC & dat);

  delayMicroseconds(1);
  PORTC |= 0x0F; // Set nWR pins high
  delayMicroseconds(1);
}

void TFT_INIT(void) {
  // Turn display off
  TFT_SEND_CMD(0x28);
  // Exit sleep mode
  TFT_SEND_CMD(0x11);
  delay(10);

  TFT_SEND_CMD(0x36);

  TFT_SEND_CMD(0x36);    //MADCTL: memory data access control
  TFT_SEND_DATA(0x80);       // MY (row address order) = 1  :: MX,MV,ML,RGB = 0

#ifdef MODE_18BPP
  TFT_SEND_CMD(0x3A);    //COLMOD: Interface Pixel format *** 262K-colors in 18bit/pixel format when using 8-bit interface to allow 3-bytes per pixel
  TFT_SEND_DATA(0x66);
#else
  TFT_SEND_CMD(0x3A);  //COLMOD: Interface Pixel format  *** 65K-colors in 16bit/pixel (5-6-5) format when using 16-bit interface to allow 1-byte per pixel
  TFT_SEND_DATA(0x55);
#endif

  TFT_SEND_CMD(0xB2);    //PORCTRK: Porch setting
  TFT_SEND_DATA(0x0C);
  TFT_SEND_DATA(0x0C);
  TFT_SEND_DATA(0x00);
  TFT_SEND_DATA(0x33);
  TFT_SEND_DATA(0x33);
 
  TFT_SEND_CMD(0xB7);    //GCTRL: Gate Control
  TFT_SEND_DATA(0x35);
 
  TFT_SEND_CMD(0xBB);    //VCOMS: VCOM setting
  TFT_SEND_DATA(0x2B);
 
  TFT_SEND_CMD(0xC0);    //LCMCTRL: LCM Control
  TFT_SEND_DATA(0x2C);
 
  TFT_SEND_CMD(0xC2);    //VDVVRHEN: VDV and VRH Command Enable
  TFT_SEND_DATA(0x01);
  TFT_SEND_DATA(0xFF);
 
  TFT_SEND_CMD(0xC3);    //VRHS: VRH Set
  TFT_SEND_DATA(0x11);
 
  TFT_SEND_CMD(0xC4);    //VDVS: VDV Set
  TFT_SEND_DATA(0x20);
 
  TFT_SEND_CMD(0xC6);    //FRCTRL2: Frame Rate control in normal mode
  TFT_SEND_DATA(0x0F);
 
  TFT_SEND_CMD(0xD0);    //PWCTRL1: Power Control 1
  TFT_SEND_DATA(0xA4);
  TFT_SEND_DATA(0xA1);
 
  TFT_SEND_CMD(0xE0);    //PVGAMCTRL: Positive Voltage Gamma control 
  TFT_SEND_DATA(0xD0);
  TFT_SEND_DATA(0x00);
  TFT_SEND_DATA(0x05);
  TFT_SEND_DATA(0x0E);
  TFT_SEND_DATA(0x15);
  TFT_SEND_DATA(0x0D);
  TFT_SEND_DATA(0x37);
  TFT_SEND_DATA(0x43);
  TFT_SEND_DATA(0x47);
  TFT_SEND_DATA(0x09);
  TFT_SEND_DATA(0x15);
  TFT_SEND_DATA(0x12);
  TFT_SEND_DATA(0x16);
  TFT_SEND_DATA(0x19);
 
  TFT_SEND_CMD(0xE1);    //NVGAMCTRL: Negative Voltage Gamma control 
  TFT_SEND_DATA(0xD0);
  TFT_SEND_DATA(0x00);
  TFT_SEND_DATA(0x05);
  TFT_SEND_DATA(0x0D);
  TFT_SEND_DATA(0x0C);
  TFT_SEND_DATA(0x06);
  TFT_SEND_DATA(0x2D);
  TFT_SEND_DATA(0x44);
  TFT_SEND_DATA(0x40);
  TFT_SEND_DATA(0x0E);
  TFT_SEND_DATA(0x1C);
  TFT_SEND_DATA(0x18);
  TFT_SEND_DATA(0x16);
  TFT_SEND_DATA(0x19);
 
  // Set Window Size to 240x320
  TFT_SEND_CMD(0x2A);    //X address set
  TFT_SEND_DATA(0x00);       // Start from...
  TFT_SEND_DATA(0x00);       // .... 0
  TFT_SEND_DATA(0x00);       // End at...
  TFT_SEND_DATA(0xEF);       // ... 239

  TFT_SEND_CMD(0x2B);    //Y address set
  TFT_SEND_DATA(0x00);       // Start from...
  TFT_SEND_DATA(0x00);       // ... 0
  TFT_SEND_DATA(0x01);       // End at...
  TFT_SEND_DATA(0x3F);       // ... 319
  delay(10);
 
  TFT_SEND_CMD(0x29);  //fill_display ON
  delay(10);
}

void COLOUR_DISPLAY(uint16_t colour)
{
  uint8_t colourR;
  uint8_t colourG;
  uint8_t colourB;

#ifdef MODE_18BPP
  // (0brrrr_rggg_ggbb_bbbx)
  colourR = (byte) (colour >> 10)&(0x3E);
  colourR |= (colour)&(0x01);
  colourR <<= 2;
 
  colourG = (byte) (colour >> 5)&(0x3E);
  colourG |= (colour)&(0x01);
  colourG <<= 2;
 
  colourB = (byte) (colour << 2)&(0xFC);

#else
  // (0brrrr_rggg_gggb_bbbb)
  colourR = highByte(colour);
  colourG = lowByte(colour);
#endif
 
  TFT_SEND_CMD(0x2C);          //command to begin writing to frame memory
 
  for(int x=0; x < 320; x++)
  {
    for(int y=0; y < 240; y++)
    {
      TFT_SEND_DATA(colourR);     // Red    0bDDDDDDxx
      TFT_SEND_DATA(colourG);     // Green  0bDDDDDDxx      // x =don't care; D = 0 or 1
     
      #ifdef MODE_18BPP
      TFT_SEND_DATA(colourB);     // Blue   0bDDDDDDxx
      #endif
    }
  }
}

void setup() {
  DDRD |= 0xFC;  // PORTD[7:2]
  PORTD &= 0x03;

  DDRB |= 0x03;  // PORTB[1:0]
  PORTB &= 0xFC;

  DDRC |= 0x0F;  // PORTC[3:0]
  PORTC |= 0x0F; // Control pins are active low, so set the Control pins high

  digitalWrite(nRS, LOW);
  delayMicroseconds(15);
  digitalWrite(nRS, HIGH);
  delay(150);
 
  TFT_INIT();
}

void loop() {
  delay(1000);
  COLOUR_DISPLAY(RED);
 
  delay(1000);
  COLOUR_DISPLAY(GREEN);

  delay(1000);
  COLOUR_DISPLAY(BLUE);
}

 

Blank Display on NHD‐C0220BiZ‐FS(RGB)‐FBW‐3VM

Started by SteveCBoard Character LCDs

Replies: 3
Views: 8065
Last post May 13, 2014, 12:04:36 AM
by SteveC
NHD‐C12864A1Z‐FSW‐FBW‐HTT display clears after draw

Started by EdAverillBoard Graphic LCDs

Replies: 6
Views: 9826
Last post November 07, 2014, 08:25:20 AM
by Michael_L
NHD‐4.3‐480272EF‐ATXL#‐CTP | FAN5333 | BBB | Nothing on the Display

Started by Alias_AliasBoard TFTs

Replies: 1
Views: 6878
Last post September 25, 2015, 03:09:24 PM
by Paul_B
Arduino LCD library not working with newhaven display NHD‐0420H1Z‐FL‐GWB-3V3

Started by c2hollowBoard Character LCDs

Replies: 9
Views: 15580
Last post July 10, 2014, 08:46:06 AM
by Michael_L
NHD-0420DZW-AG5 - Display "sometimes" shows only 2 lines

Started by stylonurusBoard OLEDs

Replies: 5
Views: 9332
Last post June 18, 2014, 10:09:49 AM
by Michael_L