NHD-5.7-320240WFB-CTXI #-T-1
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)>>; //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)>>; //SET start page address=0
TFT_Write_Data(s_x);
TFT_Write_Data((e_x)>>; //SET end page address=319
TFT_Write_Data(e_x);
TFT_Write_Command(0x2b); //SET column address
TFT_Write_Data((s_y)>>; //SET start column address=0
TFT_Write_Data(s_y);
TFT_Write_Data((e_y)>>; //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,
-
Please try to use the example code provided here: https://newhavendisplay.com/content/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.0 -
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
thanks0 -
another question
i didn't drive the TFT back light ---- did it effect on the display data
thanks0 -
The U/D and R/L pins are to be left unconnected, as they are tied internally.
0 -
i'm very thanks for you
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,0 -
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.
0 -
i'm very thanks for your help
0
Please sign in to leave a comment.
Comments
7 comments