Author Topic: ATSAM4E -NHD-2.4-240320CF-CTXI#-F - White Screen  (Read 2092 times)

gentlemann

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
ATSAM4E -NHD-2.4-240320CF-CTXI#-F - White Screen
« on: February 17, 2016, 02:49:10 PM »
Same problem as most. I have tried rewriting this several times with no luck. Reaching out for some help. Here is my code. I do see the pins switching on my scope so I think it may be a timing issue? I am running at 96MHz.

Code: [Select]

#define DISP_IM0         PIO_PC18_IDX
#define DISP_RES         PIO_PC19_IDX
#define DISP_RD PIO_PC20_IDX
#define DISP_WR PIO_PC21_IDX
#define DISP_DC PIO_PC22_IDX
#define DISP_CS PIO_PC23_IDX

#define DISP_D0 PIO_PD0_IDX
#define DISP_D1 PIO_PD1_IDX
#define DISP_D2 PIO_PD2_IDX
#define DISP_D3 PIO_PD3_IDX
#define DISP_D4 PIO_PD4_IDX
#define DISP_D5 PIO_PD5_IDX
#define DISP_D6 PIO_PD6_IDX
#define DISP_D7 PIO_PD7_IDX
#define DISP_D8 PIO_PD8_IDX
#define DISP_D9 PIO_PD9_IDX
#define DISP_D10         PIO_PD10_IDX
#define DISP_D11         PIO_PD11_IDX
#define DISP_D12         PIO_PD12_IDX
#define DISP_D13         PIO_PD13_IDX
#define DISP_D14        PIO_PD14_IDX
#define DISP_D15         PIO_PD15_IDX


#define delaydisp 10 // playing with the delay




void comm_out(unsigned int c)
{
ioport_set_pin_level(DISP_DC,OFF);
ioport_set_pin_level(DISP_RD,ON);
ioport_set_pin_level(DISP_WR,OFF);
ioport_set_port_level(IOPORT_PIOD,0xFF,c);

delay_us(delaydisp);
ioport_set_pin_level(DISP_WR,ON);
delay_us(1);

}

void data_out(unsigned int d)
{
ioport_set_pin_level(DISP_DC,ON);
ioport_set_pin_level(DISP_WR,OFF);
ioport_set_port_level(IOPORT_PIOD,0xFF,d);
delay_us(delaydisp);
ioport_set_pin_level(DISP_WR,ON);
delay_us(1);
}
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 display_setup()
{

ioport_set_pin_dir(DISP_IM0,IOPORT_DIR_OUTPUT);
ioport_set_pin_dir(DISP_RES,IOPORT_DIR_OUTPUT);
ioport_set_pin_dir(DISP_RD,IOPORT_DIR_OUTPUT);
ioport_set_pin_dir(DISP_WR,IOPORT_DIR_OUTPUT);
ioport_set_pin_dir(DISP_DC,IOPORT_DIR_OUTPUT);
ioport_set_pin_dir(DISP_CS,IOPORT_DIR_OUTPUT);

ioport_set_pin_level(DISP_IM0,ON);
ioport_set_pin_level(DISP_CS,OFF);

ioport_set_port_dir(IOPORT_PIOD,0xFF,IOPORT_DIR_OUTPUT);

ioport_set_pin_level(DISP_RD,ON);
ioport_set_pin_level(DISP_WR,OFF);
ioport_set_pin_level(DISP_RES,OFF);
delay_ms(250);
ioport_set_pin_level(DISP_RES,ON);
delay_ms(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_ms(10);
}



gentlemann

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: ATSAM4E -NHD-2.4-240320CF-CTXI#-F - White Screen
« Reply #1 on: February 18, 2016, 12:50:23 PM »
Got it working. I am Using the ST7789S. I will post an update with a working example once I flush out a couple issues. Hopefully it can help someone down the road. The main issue was forgetting to shift the bits. However the examples also are configuring the wrong registers since its on a different driver.

Paul_B

  • Administrator
  • Sr. Member
  • *****
  • Posts: 248
  • Karma: 16
    • View Profile
Re: ATSAM4E -NHD-2.4-240320CF-CTXI#-F - White Screen
« Reply #2 on: February 18, 2016, 01:08:35 PM »
Glad to hear you got your display up and running!

Thanks for sharing your solution, it will definitely help  ;)

 

NHD‐2.4‐240320SF‐CTXL#‐FTN1 touch-screen problem

Started by hbcelebiBoard TFTs

Replies: 5
Views: 4162
Last post December 10, 2014, 11:19:05 AM
by Michael_L
NHD-1.8-128160EF-CTXI ili9163 & SAM3s driver help needed

Started by JsaggioBoard TFTs

Replies: 0
Views: 1716
Last post February 01, 2016, 01:02:58 AM
by Jsaggio
Shift position after "clear screen" instruction

Started by dreissBoard OLEDs

Replies: 5
Views: 3050
Last post September 18, 2015, 03:50:30 PM
by Saurabh_B
NHD-1.8-128160EF-CTXI# problem: becomes pale after using it for some time

Started by fvdhoefBoard TFTs

Replies: 1
Views: 2939
Last post July 31, 2014, 08:55:40 AM
by Michael_L
Writing Character strings to NHD-1.8-128160EF-CTXI#

Started by JeffJwayBoard TFTs

Replies: 3
Views: 2624
Last post July 13, 2016, 09:45:21 AM
by Michael_L