Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - gentlemann

Pages: [1]
1
TFTs / 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);
}



Pages: [1]