Author Topic: NHD-2.8-240320AF-CSXP-FCTP and ARDUINO UNO  (Read 145 times)

rrubiocastil

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
NHD-2.8-240320AF-CSXP-FCTP and ARDUINO UNO
« on: November 03, 2019, 12:47:52 PM »
I use 262K-colors in 18bit/pixel format (8 bit interface) and it does not work. All I see is a random white line. The screen goes to black when I disable the Display ON command. Here is my code:

void setup() {

DDRD = 0xff;  // output (port D)

//set pins as outputs
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);

//control pin definitions
#define CS2HIGH()  digitalWrite(8, HIGH);
#define CS2LOW()  digitalWrite(8, LOW);
#define WR2HIGH()  digitalWrite(9, HIGH);
#define WR2LOW()  digitalWrite(9, LOW);
#define DCX2HIGH()  digitalWrite(10, HIGH);
#define DCX2LOW()  digitalWrite(10, LOW);
#define RD2HIGH()  digitalWrite(11, HIGH);
#define RD2LOW()  digitalWrite(11, LOW);
#define RESET2HIGH()   digitalWrite(12, HIGH);
#define RESET2LOW()   digitalWrite(12, LOW);

/////////////////////// prototypes ////////////////////////////
void TFT_28_7789_Write_Command(unsigned int command);
void TFT_28_7789_Write_Data(unsigned int data);
void TFT_28_7789_Init(void);


   
    TFT_28_7789_Init();
   
   

}

void loop() {

   
 
}


void TFT_28_7789_Write_Command(unsigned int command)
{
CS2LOW(); //GPIO_ResetBits(GPIOC, CS1);
DCX2LOW(); //GPIO_ResetBits(GPIOC, RS);
RD2HIGH(); //GPIO_SetBits(GPIOC, nRD);
WR2LOW(); //GPIO_ResetBits(GPIOC, nWR);
PORTD = command; //GPIO_Write(GPIOB, command); 8-bit interface (DB17:10)
delay(10);
WR2HIGH(); //GPIO_SetBits(GPIOC, nWR);
delay(10);
}

void TFT_28_7789_Write_Data(unsigned int data1)
{
PORTD = data1; //GPIO_Write(GPIOB, data1);//when using 16-bit interface (DB17:10,DB8:1)//when using 8-bit interface (DB17:10)
DCX2HIGH(); //GPIO_SetBits(GPIOC, RS);
WR2LOW(); //GPIO_ResetBits(GPIOC, nWR);
delay(1);
WR2HIGH(); //GPIO_SetBits(GPIOC, nWR);
}


void TFT_28_7789_Init(void)
{
CS2LOW(); //GPIO_ResetBits(GPIOC, CS1);
RD2HIGH(); //GPIO_SetBits(GPIOC, nRD);
WR2LOW(); //GPIO_ResetBits(GPIOC, nWR);
RESET2LOW(); //GPIO_WriteBit(GPIOC, RES, Bit_RESET); //reset por HW
delay(250);
RESET2HIGH(); //GPIO_WriteBit(GPIOC, RES, Bit_SET); (influye)
delay(250);

//exit SLEEP mode (SLEEP OUT))
TFT_28_7789_Write_Command(0x0011); //influye
delay(100);

//MADCTL: memory data access control
TFT_28_7789_Write_Command(0x0036);
TFT_28_7789_Write_Data(0x0080); 

//Pixel format set
TFT_28_7789_Write_Command(0x003A);
TFT_28_7789_Write_Data(0x0055);

//INVON: Display Inversion ON (setting for IPS)
TFT_28_7789_Write_Command(0x0021);

//PORCTRK: Porch setting
TFT_28_7789_Write_Command(0x00B2);
TFT_28_7789_Write_Data(0x000C);
TFT_28_7789_Write_Data(0x0C);
TFT_28_7789_Write_Data(0x00);
TFT_28_7789_Write_Data(0x33);
TFT_28_7789_Write_Data(0x33);

//GCTRL: Gate Control
TFT_28_7789_Write_Command(0x00B7);
TFT_28_7789_Write_Data(0x0035);

//VCOMS: VCOM setting
TFT_28_7789_Write_Command(0x00BB);
TFT_28_7789_Write_Data(0x002B);

//LCMCTRL: LCM Control
TFT_28_7789_Write_Command(0x00C0);
TFT_28_7789_Write_Data(0x002C);

//VDVVRHEN: VDV and VRH Command Enable
TFT_28_7789_Write_Command(0x00C2);
TFT_28_7789_Write_Data(0x0001);
TFT_28_7789_Write_Data(0xFF);

//VRHS: VRH Set
TFT_28_7789_Write_Command(0x00C3);
TFT_28_7789_Write_Data(0x0011);

//VDVS: VDV Set
TFT_28_7789_Write_Command(0x00C4);
TFT_28_7789_Write_Data(0x0020);

//FRCTRL2: Frame Rate control in normal mode
TFT_28_7789_Write_Command(0x00C6);
TFT_28_7789_Write_Data(0x000F);

//PWCTRL1: Power Control 1 (6.8, -4.8, 2.3)
TFT_28_7789_Write_Command(0x00D0);
TFT_28_7789_Write_Data(0x00A4);
TFT_28_7789_Write_Data(0xA1);

//PVGAMCTRL: Positive Voltage Gamma control
TFT_28_7789_Write_Command(0x00E0);
                  TFT_28_7789_Write_Data(0x00D0);
                  TFT_28_7789_Write_Data(0x0000);
                  TFT_28_7789_Write_Data(0x0005);
                  TFT_28_7789_Write_Data(0x000E);
                  TFT_28_7789_Write_Data(0x0015);
                  TFT_28_7789_Write_Data(0x000D);
                  TFT_28_7789_Write_Data(0x0037);
                  TFT_28_7789_Write_Data(0x0043);
                  TFT_28_7789_Write_Data(0x0047);
                  TFT_28_7789_Write_Data(0x0009);
                  TFT_28_7789_Write_Data(0x0015);
                  TFT_28_7789_Write_Data(0x0012);
                  TFT_28_7789_Write_Data(0x0016);
                  TFT_28_7789_Write_Data(0x0019);

//NVGAMCTRL: Negative Voltage Gamma control
TFT_28_7789_Write_Command(0x00E1);
                  TFT_28_7789_Write_Data(0x00D0);
                  TFT_28_7789_Write_Data(0x0000);
                  TFT_28_7789_Write_Data(0x0005);
                  TFT_28_7789_Write_Data(0x000D);
                  TFT_28_7789_Write_Data(0x000C);
                  TFT_28_7789_Write_Data(0x0006);
                  TFT_28_7789_Write_Data(0x002D);
                  TFT_28_7789_Write_Data(0x0044);
                  TFT_28_7789_Write_Data(0x0040);
                  TFT_28_7789_Write_Data(0x000E);
                  TFT_28_7789_Write_Data(0x001C);
                  TFT_28_7789_Write_Data(0x0018);
                  TFT_28_7789_Write_Data(0x0016);
                  TFT_28_7789_Write_Data(0x0019);


//X address set (CASET) de 0 a 239
TFT_28_7789_Write_Command(0x002A);
TFT_28_7789_Write_Data(0x0000);
TFT_28_7789_Write_Data(0x0000);
TFT_28_7789_Write_Data(0x0000);
TFT_28_7789_Write_Data(0x00EF);

//Y address set (PASET) de 0 a 319
TFT_28_7789_Write_Command(0x002B);
TFT_28_7789_Write_Data(0x0000);
TFT_28_7789_Write_Data(0x0000);
TFT_28_7789_Write_Data(0x0001);
TFT_28_7789_Write_Data(0x003F);

delay(10);

//Display ON
TFT_28_7789_Write_Command(0x0029);


  //RGB definition
    unsigned int Rcolor;
    unsigned int Gcolor;
    unsigned int Bcolor;
   
    Rcolor = 0b11110100;
    Gcolor = 0b10000100;
    Bcolor = 0b00110100;
     
TFT_28_7789_Write_Command(0x002C); 
    TFT_28_7789_Write_Data(0x0a);
    TFT_28_7789_Write_Data(0x0c);
    TFT_28_7789_Write_Data(0x0b);

}


************

All I get is this: https://ibb.co/QbmKxNv

Any suggestions?




Alee_S

  • Administrator
  • Jr. Member
  • *****
  • Posts: 64
  • Karma: 4
    • View Profile
Re: NHD-2.8-240320AF-CSXP-FCTP and ARDUINO UNO
« Reply #1 on: November 08, 2019, 03:35:27 PM »
This topic is currently being supported via e-mail.


 

Arduino LCD library not working with newhaven display NHD‐0420H1Z‐FL‐GWB-3V3

Started by c2hollowBoard Character LCDs

Replies: 9
Views: 21440
Last post July 10, 2014, 08:46:06 AM
by Michael_L
Can we play video from SD card on 4.3" arduino shield touch screen?

Started by lmsbioBoard TFTs

Replies: 0
Views: 44
Last post January 23, 2020, 04:42:06 PM
by lmsbio
MOVED: 320x240 sunlight readable dispaly to arduino + library

Started by Michael_LBoard Customer Projects

Replies: 0
Views: 7909
Last post October 23, 2015, 11:45:28 AM
by Michael_L
Arduino demo code for running the NHD-0420DZW-AB5 OLED display via SPI

Started by llameroBoard OLEDs

Replies: 1
Views: 5464
Last post May 21, 2018, 11:28:30 AM
by Ted_M
How do I stack a DAC shield between a 4.3" LCD Display and an Arduino Mega 2560?

Started by wa6htpBoard Customer Projects

Replies: 1
Views: 3730
Last post September 19, 2018, 09:14:45 AM
by Ted_M