Author Topic: NHD-5.7-320240WFB-CTXI #-T-1  (Read 4257 times)

karimaly08

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
NHD-5.7-320240WFB-CTXI #-T-1
« on: October 22, 2014, 03:10:39 AM »
Hello,

I started a new project using NHD-5.7-320240WFB-CTXI  TFT display

but i have a problem in starting

i write a simple code to start , but nothing display on the screen

i using a PIC18F4620 uC , crystal freq. is 4 MHz

i used the example code   http://www.newhavendisplay.com/app_notes/NHD-5.7-320240WFB-CTXI-1.txt   and doing some modifications but i can't start

my code is

char Oled_DataPort at PORTB ;

sbit TFT_CS1 at RD4_bit ;
sbit TFT_RES at RC7_bit ;
sbit TFT_DC at RD5_bit ;
sbit TFT_WR at RD6_bit ;
sbit TFT_E1 at RD7_bit ;
///////////////////////////

sbit Rad_Read at RC0_bit ;
sbit Rad_EN at RC1_bit ;
//////////////////////////

sbit Buck at RC2_bit ;
sbit Relay at RD0_bit ;
sbit Buzzer at RD1_bit ;
sbit Red_LED at RD2_bit ;
/////////////////////////

unsigned int k ;
unsigned int m ;

//--------------------------------------------------------------------------
//send Command to OLED
//--------------------------------------------------------------------------
void TFT_Write_Command(unsigned char Data)
{
TFT_E1 = 1 ;
     Oled_DataPort = Data ;                 //8080 mode
TFT_DC = 0 ;

TFT_WR = 0 ;
      TFT_CS1 = 0 ;
      TFT_CS1 = 1 ;

TFT_WR = 1;

}

//--------------------------------------------------------------------------
//send Data to OLED
//--------------------------------------------------------------------------
void TFT_Write_Data(unsigned char Data)
{
TFT_E1 = 1 ;
     Oled_DataPort = Data ;                 //8080 mode
TFT_DC = 1 ;

TFT_WR = 0 ;
      TFT_CS1 = 0 ;
      TFT_CS1 = 1 ;

TFT_WR = 1;

}
//--------------------------------------------------------------------------

void TFT_Command_Write(unsigned char REG,unsigned char VALUE)
{
TFT_Write_Command(REG);
TFT_Write_Data(VALUE);
}


//======================================================
void SendData(unsigned long color)
{
TFT_Write_Data((color)>>16);        //red
TFT_Write_Data((color)>>8);                //green
TFT_Write_Data(color);                        //blue
}
//======================================================
// initialize controller
//======================================================
void Init_SSD1963 ()
{
  TFT_RES = 0;
  delay_ms(5);
  TFT_RES = 1;
  delay_ms(100);
  TFT_Write_Command(0x01);     //Software Reset
  delay_ms(10);

  TFT_Write_Command(0xe2);       //    adust PLL freq = 100 MHz     ?????
  TFT_Write_Data(0x1D);
  TFT_Write_Data(0x02);
  TFT_Write_Data(0x04);
  TFT_Command_Write(0xe0,0x01);    //START PLL
  delay_ms(100);                                   //// ?????
  TFT_Command_Write(0xe0,0x03);    //LOCK PLL      use PLL as system clock

  TFT_Write_Command(0xb0);                //SET LCD MODE  SET TFT 18Bits MODE
  TFT_Write_Data(0x0c);                        //SET TFT MODE & hsync+Vsync+DEN MODE
  TFT_Write_Data(0x00);                        //SET TFT MODE & hsync+Vsync+DEN MODE
  TFT_Write_Data(0x01);                        //SET horizontal size=320-1 HightByte
  TFT_Write_Data(0x3f);                    //SET horizontal size=320-1 LowByte
  TFT_Write_Data(0x00);                        //SET vertical size=240-1 HightByte
  TFT_Write_Data(0xef);                        //SET vertical size=240-1 LowByte
  TFT_Write_Data(0x00);                        //SET even/odd line RGB seq.=RGB

  TFT_Command_Write(0xf0,0x00);        //SET pixel data I/F format=8bit
  TFT_Write_Command(0xe6);                   //SET PCLK freq=6.4MHz  ; pixel clock frequency
  TFT_Write_Data(0x00);
  TFT_Write_Data(0xe7);
  TFT_Write_Data(0x4f);
  TFT_Write_Command(0xb4);                //SET HBP,
  TFT_Write_Data(0x01);                        //SET HSYNC Total 440
  TFT_Write_Data(0xb8);
  TFT_Write_Data(0x00);                        //SET HBP 68
  TFT_Write_Data(0x44);
  TFT_Write_Data(0x0f);                        //SET VBP 16=15+1
  TFT_Write_Data(0x00);                        //SET Hsync pulse start position
  TFT_Write_Data(0x00);
  TFT_Write_Data(0x00);                        //SET Hsync pulse subpixel start position
  TFT_Write_Command(0xb6);                 //SET VBP,
  TFT_Write_Data(0x01);                        //SET Vsync total 265=264+1
  TFT_Write_Data(0x08);
  TFT_Write_Data(0x00);                        //SET VBP=19
  TFT_Write_Data(0x13);
  TFT_Write_Data(0x07);                        //SET Vsync pulse 8=7+1
  TFT_Write_Data(0x00);                        //SET Vsync pulse start position
  TFT_Write_Data(0x00);
  TFT_Write_Command(0x2a);                //SET column address
  TFT_Write_Data(0x00);                        //SET start column address=0
  TFT_Write_Data(0x00);
  TFT_Write_Data(0x01);                        //SET end column address=319
  TFT_Write_Data(0x3f);
  TFT_Write_Command(0x2b);                //SET page address
  TFT_Write_Data(0x00);                        //SET start page address=0
  TFT_Write_Data(0x00);
  TFT_Write_Data(0x00);                        //SET end page address=239
  TFT_Write_Data(0xef);
  TFT_Write_Command(0x29);                //SET display on
 }
//======================================================
void WindowSet(unsigned int s_x,unsigned int e_x,unsigned int s_y,unsigned int e_y)
{
  TFT_Write_Command(0x2a);                //SET page address
  TFT_Write_Data((s_x)>>8);                        //SET start page address=0
  TFT_Write_Data(s_x);
  TFT_Write_Data((e_x)>>8);                        //SET end page address=319
  TFT_Write_Data(e_x);

  TFT_Write_Command(0x2b);                //SET column address
  TFT_Write_Data((s_y)>>8);                        //SET start column address=0
  TFT_Write_Data(s_y);
  TFT_Write_Data((e_y)>>8);                        //SET end column address=239
  TFT_Write_Data(e_y);

 }
//=======================================
void FULL_ON(unsigned long dat)
{
  unsigned char x,y;
  WindowSet(0x0000,0x013f,0x0000,0x00ef);
  TFT_Write_Command(0x2c);
  for(x=0;x<240;x++)
 {
   for(y= 0;y<320;y++)
   {
         SendData(dat);
    }
  }
 }
//=======================================
void QUADS()
{
  unsigned int i,j;
  WindowSet(0x0000,0x013f,0x0000,0x00ef);
  TFT_Write_Command(0x2c);
  for(j= 0 ;j<120;j++)
   {
     for(i=0;i<160;i++)
     {
       SendData(0x0000FF);             //blue
      }
     for(i=0;i<160;i++)
     {
      SendData(0xFF0000);             //red
      }
    }
  for(j= 0 ;j<120;j++)
   {
     for(i=0;i<160;i++)
     {
       SendData(0xFFFF00);             //yellow
      }
     for(i=0;i<160;i++)
     {
       SendData(0x00FF00);             //green
      }
    }
 }

void main ()
{

  CMCON  |= 0x07;
  ADCON1 = 0B00001101 ;      // RA0 & RA1 are analog , others is digital
  ADCON2 = 0B10101100;       // Right justified , Aqusation time  = 0 because i add it manualy befor conversion , Tad = 4*Tck  (for 4 MHz Oscillator)
                             // If we use 12 MHz Oscillator the Tad shloud be vary to another value according to the data sheet
  TRISA = 0xFF ;             // all is i/p
  TRISB = 0 ;
  TRISC = 0B01000001 ;
  TRISD = 0 ;               // PORTD is o/p port
  TRISE0_bit = 1 ;
  TRISE1_bit = 1 ;
  TRISE2_bit = 1 ;

  Buzzer = 0 ;             // Driving Buzzer ON
  Delay_ms(2000);
  Buzzer = 1 ;             // Driving Buzzer OFF
  Buck = 0 ;               // Buck is off

 Init_SSD1963();
 
  while(1){

   delay_ms(5);
   QUADS();
   //delayms(2000);
   FULL_ON(0xff0000);      //red
   //delayms(2000);
   FULL_ON(0x00ff00);      //green
   //delayms(2000);
   FULL_ON(0x0000ff);      //blue
   //delayms(2000);
  }




}    // End main


thanks for all,



Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD-5.7-320240WFB-CTXI #-T-1
« Reply #1 on: October 22, 2014, 08:11:10 AM »
Please try to use the example code provided here: http://www.newhavendisplay.com/app_notes/Arduino_nhd-5_7-320240WFB.txt.
You will notice a main difference is the write command and data routines.  Try changing your functions to these and see if the display works.  Also, for simplicity sake, you may tie the /CS (chip select) line to ground, as I have done in that example code.  Let me know if this works for you.

karimaly08

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
Re: NHD-5.7-320240WFB-CTXI #-T-1
« Reply #2 on: October 23, 2014, 02:21:26 AM »
THANKS FOR YOUR HELP

BUT I HAVE ANOTHER QUESTION

what about the U/D and R/L pins (pin 16 & 17)  ?? did i externally give it 0 and VCC or it take it internally

thanks :)

karimaly08

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
Re: NHD-5.7-320240WFB-CTXI #-T-1
« Reply #3 on: October 23, 2014, 02:31:31 AM »
another question

i didn't drive the TFT back light ---- did it effect on the display data ???

thanks

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD-5.7-320240WFB-CTXI #-T-1
« Reply #4 on: October 28, 2014, 08:00:34 AM »
The U/D and R/L pins are to be left unconnected, as they are tied internally.

karimaly08

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
Re: NHD-5.7-320240WFB-CTXI #-T-1
« Reply #5 on: November 04, 2014, 06:32:08 AM »
i'm very thanks for you  :D

the code is working good

but i need a program to convert the jpg or bmp to a C file , can you help me

thanks, :)

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD-5.7-320240WFB-CTXI #-T-1
« Reply #6 on: November 04, 2014, 07:55:27 AM »
You can try programs like Frhed, Hex Workshop, LCD assistant, etc.  Try searching the internet for programs to extract the hex data from a bmp.

karimaly08

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
Re: NHD-5.7-320240WFB-CTXI #-T-1
« Reply #7 on: November 05, 2014, 05:10:20 AM »
 :)

i'm very thanks for your help

 

NHD-2.4-240320CF-CTXI#-FT (ST7789S controller) and STM32F4 FSMC LCD Interface

Started by deshayesBoard TFTs

Replies: 1
Views: 2684
Last post March 17, 2016, 06:25:18 PM
by fahad
NHDEV firmware to support NHD-2.4-240320CF-CTXI#-FT (ST7889S controller)

Started by deshayesBoard Evaluation Tools

Replies: 2
Views: 2646
Last post November 23, 2017, 03:56:56 AM
by tolikkk
NHD-1.8-128160EF-CTXI ili9163 & SAM3s driver help needed

Started by JsaggioBoard TFTs

Replies: 0
Views: 1728
Last post February 01, 2016, 01:02:58 AM
by Jsaggio
NHD-1.8-128160EF-CTXI# problem: becomes pale after using it for some time

Started by fvdhoefBoard TFTs

Replies: 1
Views: 2966
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: 2649
Last post July 13, 2016, 09:45:21 AM
by Michael_L