Interface PIC32MZ2064DAB176 with 5'' tft display

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, everyone

 

I am a newbie here

I am working with PIC32MZ2064DAB176 and want to interface a 5'' TFT touch display.

Below I have uploaded the datasheet of the display which uses NT35510 Driver IC.

 

I have connected the pins with PIC32MZ as mentioned in both datasheets oF PIC32MZ2064DAB176 and of TFT display.

 

I have uploaded the which is shared by https://www.wandisplay.com.

 

But the code id for 8051 MCU, I have converted this code and but it's not working.

 

I am using MPLab XIDE for programming and also using Harmony V3.

 

here is the code I have made

 

/*******************************************************************************
  Main Source File

  Company:
    Microchip Technology Inc.

  File Name:
    main.c

  Summary:
    This file contains the "main" function for a project.

  Description:
    This file contains the "main" function for a project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state
    machines of all modules in the system
 *******************************************************************************/

// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "definitions.h"                // SYS function prototypes
#include "xc.h"

#define SYS_FREQ 200000000 // Running at 200MHz

//Number of rows and columns displayed
#define ROW  854
#define COL  480

//Define color constants
#define RED    0xF800
#define GREEN  0x07E0
#define BLUE   0x001F
#define WHITE  0xFFFF
#define BLACK  0x0000
#define GRAY   0xEF5D	     //0x2410
#define GRAY75 0x39E7
#define GRAY50 0x7BEF
#define GRAY25 0xADB5	

void led_blinky();
void delay_us(unsigned int us);
void delay_ms(int ms);

void Delay(unsigned int dly);
void IIC_Delay(unsigned int dly);

///////-----SPI FUNCTIONS DECLERATION---------////
void SoftSPI_Write(unsigned int val);
unsigned int SoftSPI_Read();
void SPI_SendData(unsigned int i);
void SPI_WriteComm(unsigned int i);
void SPI_WriteData(unsigned int i);
/////////////-------END OF SPI--------------------////

////////-----LCD FUNCTIONS DECLERATION-------------//////
void LCD_Init(void);
void WriteDispData(unsigned char dataH,unsigned char dataL);
void ClearAll(void);
void DispColor(unsigned int color);
void DispBand(void);
void DispFrame(void);
///////-----------------END OF LCD------------------------/////

void delay_us(unsigned int us)
{
    // Convert microseconds us into how many clock ticks it will take
    us *= SYS_FREQ / 1000000 / 2; // Core Timer updates every 2 ticks

    _CP0_SET_COUNT(0); // Set Core Timer count to 0

    while (us > _CP0_GET_COUNT()); // Wait until Core Timer count reaches the number we calculated earlier
}

void delay_ms(int ms)
{
    delay_us(ms * 1000);
}

void Delay(unsigned int dly)
{
    unsigned int i,j;

    for(i=0;i<dly;i++)
    	for(j=0;j<255;j++);
}
void IIC_Delay(unsigned int dly)
{
    unsigned int i;

    for(i=0;i<dly;i++);
}
/////////////////////SPI SECTION//////////////////////////

void SoftSPI_Write(unsigned int val)
{
    for(int i=0;i<8;i++)
    {
       if(val&0x80)
           D_MOSI_Set();
       else
           D_MOSI_Clear();
       val<<=1;

       D_SCK_Set();
       delay_us(4);
       D_SCK_Clear();
       delay_us(4);
       //val<<=1;
    }
}

unsigned int SoftSPI_Read()
{
    unsigned int val=0;
    for(int i=0;i<8;i++)
    {
    }
    return val;
}

void SPI_SendData(unsigned int i)
{
    SoftSPI_Write(i);
    //SPI1_Write(&i, (size_t)1);
}

void SPI_WriteComm(unsigned int i)
{
    CS_X_Clear(); 

	SPI_SendData(0x20);	 //high 8bit
	SPI_SendData(i>>8);

	SPI_SendData(0x00);	//low 8bit
	SPI_SendData(i);

   CS_X_Set();
}

void SPI_WriteData(unsigned int i)
{
    CS_X_Clear();

	SPI_SendData(0x40);
	SPI_SendData(i);

    CS_X_Set();
}

void LCD_Init(void)
{
/*
	SPI_RES=1;
	Delay(10);
	SPI_RES=0;
    Delay(800);
    SPI_RES=1;
	Delay(800);
*/
//		  I2C_SCL_0();
//	  I2C_SDA_1();
//		GT960_INT_0();
//
//		GT960_RST_0();
//    		IIC_Delay(400);
//		GT960_RST_1();
//
//		GT960_INT_1();
//
//	//	GPIO_Init(GPIOF,GT960_INT,GPIO_MODE_IN_FL_NO_IT);
//		Delay(200);

    RES_X_Set();
    delay_ms(150);
    RES_X_Clear();
    delay_ms(150);
    RES_X_Set();
    delay_ms(150);

#if 1

//***************************
// CMD3 (NT35510S Only)
//***************************
SPI_WriteComm(0xFF00); SPI_WriteData(0xAA);
SPI_WriteComm(0xFF01); SPI_WriteData(0x55);
SPI_WriteComm(0xFF02); SPI_WriteData(0xA5);
SPI_WriteComm(0xFF03); SPI_WriteData(0x80); 

SPI_WriteComm(0xF40A); SPI_WriteData(0x22); 

SPI_WriteComm(0xFF00); SPI_WriteData(0xAA);
SPI_WriteComm(0xFF01); SPI_WriteData(0x55);
SPI_WriteComm(0xFF02); SPI_WriteData(0xA5);
SPI_WriteComm(0xFF03); SPI_WriteData(0x00); 

//---------------------------
// CMD2, Page 1
//---------------------------
SPI_WriteComm(0xF000); SPI_WriteData(0x55);
SPI_WriteComm(0xF001); SPI_WriteData(0xAA);
SPI_WriteComm(0xF002); SPI_WriteData(0x52);
SPI_WriteComm(0xF003); SPI_WriteData(0x08);
SPI_WriteComm(0xF004); SPI_WriteData(0x01); 

// AVDD: 5.0V
SPI_WriteComm(0xB000); SPI_WriteData(0x0F);
SPI_WriteComm(0xB001); SPI_WriteData(0x0F);
SPI_WriteComm(0xB002); SPI_WriteData(0x0F); 

// AVDD: 3.0x
SPI_WriteComm(0xB600); SPI_WriteData(0x54);
SPI_WriteComm(0xB601); SPI_WriteData(0x54);
SPI_WriteComm(0xB602); SPI_WriteData(0x54); 

// AVEE: -5.0V
SPI_WriteComm(0xB100); SPI_WriteData(0x0F);
SPI_WriteComm(0xB101); SPI_WriteData(0x0F);
SPI_WriteComm(0xB102); SPI_WriteData(0x0F); 

// AVEE: -2.0x
SPI_WriteComm(0xB700); SPI_WriteData(0x24);
SPI_WriteComm(0xB701); SPI_WriteData(0x24);
SPI_WriteComm(0xB702); SPI_WriteData(0x24); 

// VCL: -3.0V
SPI_WriteComm(0xB200); SPI_WriteData(0x01);
SPI_WriteComm(0xB201); SPI_WriteData(0x01);
SPI_WriteComm(0xB202); SPI_WriteData(0x01); 

// VCL: -2.0x
SPI_WriteComm(0xB800); SPI_WriteData(0x34);
SPI_WriteComm(0xB801); SPI_WriteData(0x34);
SPI_WriteComm(0xB802); SPI_WriteData(0x34); 

// VGH: 15V (Free pump)
SPI_WriteComm(0xBF00); SPI_WriteData(0x01);
SPI_WriteComm(0xB300); SPI_WriteData(0x0F);
SPI_WriteComm(0xB301); SPI_WriteData(0x0F);
SPI_WriteComm(0xB302); SPI_WriteData(0x0F); 

// VGH: 2x AVDD - AVEE
SPI_WriteComm(0xB900); SPI_WriteData(0x34);
SPI_WriteComm(0xB901); SPI_WriteData(0x34);
SPI_WriteComm(0xB902); SPI_WriteData(0x34); 

// VGL_REG: -12V
SPI_WriteComm(0xB500); SPI_WriteData(0x0A);
SPI_WriteComm(0xB501); SPI_WriteData(0x0A);
SPI_WriteComm(0xB502); SPI_WriteData(0x0A); 

SPI_WriteComm(0xC200); SPI_WriteData(0x03); 

// VGLX: AVEE + VCL - AVDD
SPI_WriteComm(0xBA00); SPI_WriteData(0x24);
SPI_WriteComm(0xBA01); SPI_WriteData(0x24);
SPI_WriteComm(0xBA02); SPI_WriteData(0x24); 

// VGMP/VGSP: 4V/0V
SPI_WriteComm(0xBC00); SPI_WriteData(0x00);
SPI_WriteComm(0xBC01); SPI_WriteData(0x50);
SPI_WriteComm(0xBC02); SPI_WriteData(0x00); 

// VGMN/VGSN: -4V/0V
SPI_WriteComm(0xBD00); SPI_WriteData(0x00);
SPI_WriteComm(0xBD01); SPI_WriteData(0x50);
SPI_WriteComm(0xBD02); SPI_WriteData(0x00); 

// VCOM
SPI_WriteComm(0xBE00); SPI_WriteData(0x00);
SPI_WriteComm(0xBE01); SPI_WriteData(0x50); 

// R(+) MCR cmd
SPI_WriteComm(0xD100); SPI_WriteData(0x00);
SPI_WriteComm(0xD101); SPI_WriteData(0x02);
SPI_WriteComm(0xD102); SPI_WriteData(0x00);
SPI_WriteComm(0xD103); SPI_WriteData(0x60);
SPI_WriteComm(0xD104); SPI_WriteData(0x00);
SPI_WriteComm(0xD105); SPI_WriteData(0x76);
SPI_WriteComm(0xD106); SPI_WriteData(0x00);
SPI_WriteComm(0xD107); SPI_WriteData(0x8C);
SPI_WriteComm(0xD108); SPI_WriteData(0x00);
SPI_WriteComm(0xD109); SPI_WriteData(0xA1);
SPI_WriteComm(0xD10A); SPI_WriteData(0x00);
SPI_WriteComm(0xD10B); SPI_WriteData(0xC5);
SPI_WriteComm(0xD10C); SPI_WriteData(0x00);
SPI_WriteComm(0xD10D); SPI_WriteData(0xE3);
SPI_WriteComm(0xD10E); SPI_WriteData(0x01);
SPI_WriteComm(0xD10F); SPI_WriteData(0x13);
SPI_WriteComm(0xD110); SPI_WriteData(0x01);
SPI_WriteComm(0xD111); SPI_WriteData(0x38);
SPI_WriteComm(0xD112); SPI_WriteData(0x01);
SPI_WriteComm(0xD113); SPI_WriteData(0x6C);
SPI_WriteComm(0xD114); SPI_WriteData(0x01);
SPI_WriteComm(0xD115); SPI_WriteData(0x93);
SPI_WriteComm(0xD116); SPI_WriteData(0x01);
SPI_WriteComm(0xD117); SPI_WriteData(0xCE);
SPI_WriteComm(0xD118); SPI_WriteData(0x01);
SPI_WriteComm(0xD119); SPI_WriteData(0xFD);
SPI_WriteComm(0xD11A); SPI_WriteData(0x01);
SPI_WriteComm(0xD11B); SPI_WriteData(0xFF);
SPI_WriteComm(0xD11C); SPI_WriteData(0x02);
SPI_WriteComm(0xD11D); SPI_WriteData(0x29);
SPI_WriteComm(0xD11E); SPI_WriteData(0x02);
SPI_WriteComm(0xD11F); SPI_WriteData(0x53);
SPI_WriteComm(0xD120); SPI_WriteData(0x02);
SPI_WriteComm(0xD121); SPI_WriteData(0x6A);
SPI_WriteComm(0xD122); SPI_WriteData(0x02);
SPI_WriteComm(0xD123); SPI_WriteData(0x86);
SPI_WriteComm(0xD124); SPI_WriteData(0x02);
SPI_WriteComm(0xD125); SPI_WriteData(0x9A);
SPI_WriteComm(0xD126); SPI_WriteData(0x02);
SPI_WriteComm(0xD127); SPI_WriteData(0xB4);
SPI_WriteComm(0xD128); SPI_WriteData(0x02);
SPI_WriteComm(0xD129); SPI_WriteData(0xC4);
SPI_WriteComm(0xD12A); SPI_WriteData(0x02);
SPI_WriteComm(0xD12B); SPI_WriteData(0xD9);
SPI_WriteComm(0xD12C); SPI_WriteData(0x02);
SPI_WriteComm(0xD12D); SPI_WriteData(0xE7);
SPI_WriteComm(0xD12E); SPI_WriteData(0x02);
SPI_WriteComm(0xD12F); SPI_WriteData(0xFE);
SPI_WriteComm(0xD130); SPI_WriteData(0x03);
SPI_WriteComm(0xD131); SPI_WriteData(0x39);
SPI_WriteComm(0xD132); SPI_WriteData(0x03);
SPI_WriteComm(0xD133); SPI_WriteData(0xFF); 

// G(+) MCR cmd
SPI_WriteComm(0xD200); SPI_WriteData(0x00);
SPI_WriteComm(0xD201); SPI_WriteData(0x02);
SPI_WriteComm(0xD202); SPI_WriteData(0x00);
SPI_WriteComm(0xD203); SPI_WriteData(0x60);
SPI_WriteComm(0xD204); SPI_WriteData(0x00);
SPI_WriteComm(0xD205); SPI_WriteData(0x76);
SPI_WriteComm(0xD206); SPI_WriteData(0x00);
SPI_WriteComm(0xD207); SPI_WriteData(0x8C);
SPI_WriteComm(0xD208); SPI_WriteData(0x00);
SPI_WriteComm(0xD209); SPI_WriteData(0xA1);
SPI_WriteComm(0xD20A); SPI_WriteData(0x00);
SPI_WriteComm(0xD20B); SPI_WriteData(0xC5);
SPI_WriteComm(0xD20C); SPI_WriteData(0x00);
SPI_WriteComm(0xD20D); SPI_WriteData(0xE3);
SPI_WriteComm(0xD20E); SPI_WriteData(0x01);
SPI_WriteComm(0xD20F); SPI_WriteData(0x13);
SPI_WriteComm(0xD210); SPI_WriteData(0x01);
SPI_WriteComm(0xD211); SPI_WriteData(0x38);
SPI_WriteComm(0xD212); SPI_WriteData(0x01);
SPI_WriteComm(0xD213); SPI_WriteData(0x6C);
SPI_WriteComm(0xD214); SPI_WriteData(0x01);
SPI_WriteComm(0xD215); SPI_WriteData(0x93);
SPI_WriteComm(0xD216); SPI_WriteData(0x01);
SPI_WriteComm(0xD217); SPI_WriteData(0xCE);
SPI_WriteComm(0xD218); SPI_WriteData(0x01);
SPI_WriteComm(0xD219); SPI_WriteData(0xFD);
SPI_WriteComm(0xD21A); SPI_WriteData(0x01);
SPI_WriteComm(0xD21B); SPI_WriteData(0xFF);
SPI_WriteComm(0xD21C); SPI_WriteData(0x02);
SPI_WriteComm(0xD21D); SPI_WriteData(0x29);
SPI_WriteComm(0xD21E); SPI_WriteData(0x02);
SPI_WriteComm(0xD21F); SPI_WriteData(0x53);
SPI_WriteComm(0xD220); SPI_WriteData(0x02);
SPI_WriteComm(0xD221); SPI_WriteData(0x6A);
SPI_WriteComm(0xD222); SPI_WriteData(0x02);
SPI_WriteComm(0xD223); SPI_WriteData(0x86);
SPI_WriteComm(0xD224); SPI_WriteData(0x02);
SPI_WriteComm(0xD225); SPI_WriteData(0x9A);
SPI_WriteComm(0xD226); SPI_WriteData(0x02);
SPI_WriteComm(0xD227); SPI_WriteData(0xB4);
SPI_WriteComm(0xD228); SPI_WriteData(0x02);
SPI_WriteComm(0xD229); SPI_WriteData(0xC4);
SPI_WriteComm(0xD22A); SPI_WriteData(0x02);
SPI_WriteComm(0xD22B); SPI_WriteData(0xD9);
SPI_WriteComm(0xD22C); SPI_WriteData(0x02);
SPI_WriteComm(0xD22D); SPI_WriteData(0xE7);
SPI_WriteComm(0xD22E); SPI_WriteData(0x02);
SPI_WriteComm(0xD22F); SPI_WriteData(0xFE);
SPI_WriteComm(0xD230); SPI_WriteData(0x03);
SPI_WriteComm(0xD231); SPI_WriteData(0x39);
SPI_WriteComm(0xD232); SPI_WriteData(0x03);
SPI_WriteComm(0xD233); SPI_WriteData(0xFF); 

// B(+) MCR cmd
SPI_WriteComm(0xD300); SPI_WriteData(0x00);
SPI_WriteComm(0xD301); SPI_WriteData(0x02);
SPI_WriteComm(0xD302); SPI_WriteData(0x00);
SPI_WriteComm(0xD303); SPI_WriteData(0x60);
SPI_WriteComm(0xD304); SPI_WriteData(0x00);
SPI_WriteComm(0xD305); SPI_WriteData(0x76);
SPI_WriteComm(0xD306); SPI_WriteData(0x00);
SPI_WriteComm(0xD307); SPI_WriteData(0x8C);
SPI_WriteComm(0xD308); SPI_WriteData(0x00);
SPI_WriteComm(0xD309); SPI_WriteData(0xA1);
SPI_WriteComm(0xD30A); SPI_WriteData(0x00);
SPI_WriteComm(0xD30B); SPI_WriteData(0xC5);
SPI_WriteComm(0xD30C); SPI_WriteData(0x00);
SPI_WriteComm(0xD30D); SPI_WriteData(0xE3);
SPI_WriteComm(0xD30E); SPI_WriteData(0x01);
SPI_WriteComm(0xD30F); SPI_WriteData(0x13);
SPI_WriteComm(0xD310); SPI_WriteData(0x01);
SPI_WriteComm(0xD311); SPI_WriteData(0x38);
SPI_WriteComm(0xD312); SPI_WriteData(0x01);
SPI_WriteComm(0xD313); SPI_WriteData(0x6C);
SPI_WriteComm(0xD314); SPI_WriteData(0x01);
SPI_WriteComm(0xD315); SPI_WriteData(0x93);
SPI_WriteComm(0xD316); SPI_WriteData(0x01);
SPI_WriteComm(0xD317); SPI_WriteData(0xCE);
SPI_WriteComm(0xD318); SPI_WriteData(0x01);
SPI_WriteComm(0xD319); SPI_WriteData(0xFD);
SPI_WriteComm(0xD31A); SPI_WriteData(0x01);
SPI_WriteComm(0xD31B); SPI_WriteData(0xFF);
SPI_WriteComm(0xD31C); SPI_WriteData(0x02);
SPI_WriteComm(0xD31D); SPI_WriteData(0x29);
SPI_WriteComm(0xD31E); SPI_WriteData(0x02);
SPI_WriteComm(0xD31F); SPI_WriteData(0x53);
SPI_WriteComm(0xD320); SPI_WriteData(0x02);
SPI_WriteComm(0xD321); SPI_WriteData(0x6A);
SPI_WriteComm(0xD322); SPI_WriteData(0x02);
SPI_WriteComm(0xD323); SPI_WriteData(0x86);
SPI_WriteComm(0xD324); SPI_WriteData(0x02);
SPI_WriteComm(0xD325); SPI_WriteData(0x9A);
SPI_WriteComm(0xD326); SPI_WriteData(0x02);
SPI_WriteComm(0xD327); SPI_WriteData(0xB4);
SPI_WriteComm(0xD328); SPI_WriteData(0x02);
SPI_WriteComm(0xD329); SPI_WriteData(0xC4);
SPI_WriteComm(0xD32A); SPI_WriteData(0x02);
SPI_WriteComm(0xD32B); SPI_WriteData(0xD9);
SPI_WriteComm(0xD32C); SPI_WriteData(0x02);
SPI_WriteComm(0xD32D); SPI_WriteData(0xE7);
SPI_WriteComm(0xD32E); SPI_WriteData(0x02);
SPI_WriteComm(0xD32F); SPI_WriteData(0xFE);
SPI_WriteComm(0xD330); SPI_WriteData(0x03);
SPI_WriteComm(0xD331); SPI_WriteData(0x39);
SPI_WriteComm(0xD332); SPI_WriteData(0x03);
SPI_WriteComm(0xD333); SPI_WriteData(0xFF); 

// R(-) MCR cmd
SPI_WriteComm(0xD400); SPI_WriteData(0x00);
SPI_WriteComm(0xD401); SPI_WriteData(0x02);
SPI_WriteComm(0xD402); SPI_WriteData(0x00);
SPI_WriteComm(0xD403); SPI_WriteData(0x60);
SPI_WriteComm(0xD404); SPI_WriteData(0x00);
SPI_WriteComm(0xD405); SPI_WriteData(0x76);
SPI_WriteComm(0xD406); SPI_WriteData(0x00);
SPI_WriteComm(0xD407); SPI_WriteData(0x8C);
SPI_WriteComm(0xD408); SPI_WriteData(0x00);
SPI_WriteComm(0xD409); SPI_WriteData(0xA1);
SPI_WriteComm(0xD40A); SPI_WriteData(0x00);
SPI_WriteComm(0xD40B); SPI_WriteData(0xC5);
SPI_WriteComm(0xD40C); SPI_WriteData(0x00);
SPI_WriteComm(0xD40D); SPI_WriteData(0xE3);
SPI_WriteComm(0xD40E); SPI_WriteData(0x01);
SPI_WriteComm(0xD40F); SPI_WriteData(0x13);
SPI_WriteComm(0xD410); SPI_WriteData(0x01);
SPI_WriteComm(0xD411); SPI_WriteData(0x38);
SPI_WriteComm(0xD412); SPI_WriteData(0x01);
SPI_WriteComm(0xD413); SPI_WriteData(0x6C);
SPI_WriteComm(0xD414); SPI_WriteData(0x01);
SPI_WriteComm(0xD415); SPI_WriteData(0x93);
SPI_WriteComm(0xD416); SPI_WriteData(0x01);
SPI_WriteComm(0xD417); SPI_WriteData(0xCE);
SPI_WriteComm(0xD418); SPI_WriteData(0x01);
SPI_WriteComm(0xD419); SPI_WriteData(0xFD);
SPI_WriteComm(0xD41A); SPI_WriteData(0x01);
SPI_WriteComm(0xD41B); SPI_WriteData(0xFF);
SPI_WriteComm(0xD41C); SPI_WriteData(0x02);
SPI_WriteComm(0xD41D); SPI_WriteData(0x29);
SPI_WriteComm(0xD41E); SPI_WriteData(0x02);
SPI_WriteComm(0xD41F); SPI_WriteData(0x53);
SPI_WriteComm(0xD420); SPI_WriteData(0x02);
SPI_WriteComm(0xD421); SPI_WriteData(0x6A);
SPI_WriteComm(0xD422); SPI_WriteData(0x02);
SPI_WriteComm(0xD423); SPI_WriteData(0x86);
SPI_WriteComm(0xD424); SPI_WriteData(0x02);
SPI_WriteComm(0xD425); SPI_WriteData(0x9A);
SPI_WriteComm(0xD426); SPI_WriteData(0x02);
SPI_WriteComm(0xD427); SPI_WriteData(0xB4);
SPI_WriteComm(0xD428); SPI_WriteData(0x02);
SPI_WriteComm(0xD429); SPI_WriteData(0xC4);
SPI_WriteComm(0xD42A); SPI_WriteData(0x02);
SPI_WriteComm(0xD42B); SPI_WriteData(0xD9);
SPI_WriteComm(0xD42C); SPI_WriteData(0x02);
SPI_WriteComm(0xD42D); SPI_WriteData(0xE7);
SPI_WriteComm(0xD42E); SPI_WriteData(0x02);
SPI_WriteComm(0xD42F); SPI_WriteData(0xFE);
SPI_WriteComm(0xD430); SPI_WriteData(0x03);
SPI_WriteComm(0xD431); SPI_WriteData(0x39);
SPI_WriteComm(0xD432); SPI_WriteData(0x03);
SPI_WriteComm(0xD433); SPI_WriteData(0xFF); 

// G(-) MCR cmd
SPI_WriteComm(0xD500); SPI_WriteData(0x00);
SPI_WriteComm(0xD501); SPI_WriteData(0x02);
SPI_WriteComm(0xD502); SPI_WriteData(0x00);
SPI_WriteComm(0xD503); SPI_WriteData(0x60);
SPI_WriteComm(0xD504); SPI_WriteData(0x00);
SPI_WriteComm(0xD505); SPI_WriteData(0x76);
SPI_WriteComm(0xD506); SPI_WriteData(0x00);
SPI_WriteComm(0xD507); SPI_WriteData(0x8C);
SPI_WriteComm(0xD508); SPI_WriteData(0x00);
SPI_WriteComm(0xD509); SPI_WriteData(0xA1);
SPI_WriteComm(0xD50A); SPI_WriteData(0x00);
SPI_WriteComm(0xD50B); SPI_WriteData(0xC5);
SPI_WriteComm(0xD50C); SPI_WriteData(0x00);
SPI_WriteComm(0xD50D); SPI_WriteData(0xE3);
SPI_WriteComm(0xD50E); SPI_WriteData(0x01);
SPI_WriteComm(0xD50F); SPI_WriteData(0x13);
SPI_WriteComm(0xD510); SPI_WriteData(0x01);
SPI_WriteComm(0xD511); SPI_WriteData(0x38);
SPI_WriteComm(0xD512); SPI_WriteData(0x01);
SPI_WriteComm(0xD513); SPI_WriteData(0x6C);
SPI_WriteComm(0xD514); SPI_WriteData(0x01);
SPI_WriteComm(0xD515); SPI_WriteData(0x93);
SPI_WriteComm(0xD516); SPI_WriteData(0x01);
SPI_WriteComm(0xD517); SPI_WriteData(0xCE);
SPI_WriteComm(0xD518); SPI_WriteData(0x01);
SPI_WriteComm(0xD519); SPI_WriteData(0xFD);
SPI_WriteComm(0xD51A); SPI_WriteData(0x01);
SPI_WriteComm(0xD51B); SPI_WriteData(0xFF);
SPI_WriteComm(0xD51C); SPI_WriteData(0x02);
SPI_WriteComm(0xD51D); SPI_WriteData(0x29);
SPI_WriteComm(0xD51E); SPI_WriteData(0x02);
SPI_WriteComm(0xD51F); SPI_WriteData(0x53);
SPI_WriteComm(0xD520); SPI_WriteData(0x02);
SPI_WriteComm(0xD521); SPI_WriteData(0x6A);
SPI_WriteComm(0xD522); SPI_WriteData(0x02);
SPI_WriteComm(0xD523); SPI_WriteData(0x86);
SPI_WriteComm(0xD524); SPI_WriteData(0x02);
SPI_WriteComm(0xD525); SPI_WriteData(0x9A);
SPI_WriteComm(0xD526); SPI_WriteData(0x02);
SPI_WriteComm(0xD527); SPI_WriteData(0xB4);
SPI_WriteComm(0xD528); SPI_WriteData(0x02);
SPI_WriteComm(0xD529); SPI_WriteData(0xC4);
SPI_WriteComm(0xD52A); SPI_WriteData(0x02);
SPI_WriteComm(0xD52B); SPI_WriteData(0xD9);
SPI_WriteComm(0xD52C); SPI_WriteData(0x02);
SPI_WriteComm(0xD52D); SPI_WriteData(0xE7);
SPI_WriteComm(0xD52E); SPI_WriteData(0x02);
SPI_WriteComm(0xD52F); SPI_WriteData(0xFE);
SPI_WriteComm(0xD530); SPI_WriteData(0x03);
SPI_WriteComm(0xD531); SPI_WriteData(0x39);
SPI_WriteComm(0xD532); SPI_WriteData(0x03);
SPI_WriteComm(0xD533); SPI_WriteData(0xFF); 

// B(-) MCR cmd
SPI_WriteComm(0xD600); SPI_WriteData(0x00);
SPI_WriteComm(0xD601); SPI_WriteData(0x02);
SPI_WriteComm(0xD602); SPI_WriteData(0x00);
SPI_WriteComm(0xD603); SPI_WriteData(0x60);
SPI_WriteComm(0xD604); SPI_WriteData(0x00);
SPI_WriteComm(0xD605); SPI_WriteData(0x76);
SPI_WriteComm(0xD606); SPI_WriteData(0x00);
SPI_WriteComm(0xD607); SPI_WriteData(0x8C);
SPI_WriteComm(0xD608); SPI_WriteData(0x00);
SPI_WriteComm(0xD609); SPI_WriteData(0xA1);
SPI_WriteComm(0xD60A); SPI_WriteData(0x00);
SPI_WriteComm(0xD60B); SPI_WriteData(0xC5);
SPI_WriteComm(0xD60C); SPI_WriteData(0x00);
SPI_WriteComm(0xD60D); SPI_WriteData(0xE3);
SPI_WriteComm(0xD60E); SPI_WriteData(0x01);
SPI_WriteComm(0xD60F); SPI_WriteData(0x13);
SPI_WriteComm(0xD610); SPI_WriteData(0x01);
SPI_WriteComm(0xD611); SPI_WriteData(0x38);
SPI_WriteComm(0xD612); SPI_WriteData(0x01);
SPI_WriteComm(0xD613); SPI_WriteData(0x6C);
SPI_WriteComm(0xD614); SPI_WriteData(0x01);
SPI_WriteComm(0xD615); SPI_WriteData(0x93);
SPI_WriteComm(0xD616); SPI_WriteData(0x01);
SPI_WriteComm(0xD617); SPI_WriteData(0xCE);
SPI_WriteComm(0xD618); SPI_WriteData(0x01);
SPI_WriteComm(0xD619); SPI_WriteData(0xFD);
SPI_WriteComm(0xD61A); SPI_WriteData(0x01);
SPI_WriteComm(0xD61B); SPI_WriteData(0xFF);
SPI_WriteComm(0xD61C); SPI_WriteData(0x02);
SPI_WriteComm(0xD61D); SPI_WriteData(0x29);
SPI_WriteComm(0xD61E); SPI_WriteData(0x02);
SPI_WriteComm(0xD61F); SPI_WriteData(0x53);
SPI_WriteComm(0xD620); SPI_WriteData(0x02);
SPI_WriteComm(0xD621); SPI_WriteData(0x6A);
SPI_WriteComm(0xD622); SPI_WriteData(0x02);
SPI_WriteComm(0xD623); SPI_WriteData(0x86);
SPI_WriteComm(0xD624); SPI_WriteData(0x02);
SPI_WriteComm(0xD625); SPI_WriteData(0x9A);
SPI_WriteComm(0xD626); SPI_WriteData(0x02);
SPI_WriteComm(0xD627); SPI_WriteData(0xB4);
SPI_WriteComm(0xD628); SPI_WriteData(0x02);
SPI_WriteComm(0xD629); SPI_WriteData(0xC4);
SPI_WriteComm(0xD62A); SPI_WriteData(0x02);
SPI_WriteComm(0xD62B); SPI_WriteData(0xD9);
SPI_WriteComm(0xD62C); SPI_WriteData(0x02);
SPI_WriteComm(0xD62D); SPI_WriteData(0xE7);
SPI_WriteComm(0xD62E); SPI_WriteData(0x02);
SPI_WriteComm(0xD62F); SPI_WriteData(0xFE);
SPI_WriteComm(0xD630); SPI_WriteData(0x03);
SPI_WriteComm(0xD631); SPI_WriteData(0x39);
SPI_WriteComm(0xD632); SPI_WriteData(0x03);
SPI_WriteComm(0xD633); SPI_WriteData(0xFF); 

//LV2 Page 0 enable
SPI_WriteComm(0xF000); SPI_WriteData(0x55);
SPI_WriteComm(0xF001); SPI_WriteData(0xAA);
SPI_WriteComm(0xF002); SPI_WriteData(0x52);
SPI_WriteComm(0xF003); SPI_WriteData(0x08);
SPI_WriteComm(0xF004); SPI_WriteData(0x00);  // page=0

//Resolution range
SPI_WriteComm(0xB500); SPI_WriteData(0x6f);

//Display control
SPI_WriteComm(0xB100); SPI_WriteData(0xFC); //0xcc
SPI_WriteComm(0xB101); SPI_WriteData(0x00);

//Source hold time
SPI_WriteComm(0xB600); SPI_WriteData(0x05);

//Gate EQ control
SPI_WriteComm(0xB700); SPI_WriteData(0x70);
SPI_WriteComm(0xB701); SPI_WriteData(0x70);

//Source EQ control (Mode 2)
SPI_WriteComm(0xB800); SPI_WriteData(0x01);
SPI_WriteComm(0xB801); SPI_WriteData(0x03);
SPI_WriteComm(0xB802); SPI_WriteData(0x03);
SPI_WriteComm(0xB803); SPI_WriteData(0x03);

//Inversion mode  (Column)
SPI_WriteComm(0xBC00); SPI_WriteData(0x00);
SPI_WriteComm(0xBC01); SPI_WriteData(0x00);
SPI_WriteComm(0xBC02); SPI_WriteData(0x00);

//Frame rate
SPI_WriteComm(0xBD00); SPI_WriteData(0x01);
SPI_WriteComm(0xBD01); SPI_WriteData(0x84);
SPI_WriteComm(0xBD02); SPI_WriteData(0x1C);
SPI_WriteComm(0xBD03); SPI_WriteData(0x1C);
SPI_WriteComm(0xBD04); SPI_WriteData(0x00);

//Timing control 8phase dual side/4H/4delay/RST_EN
SPI_WriteComm(0xC900); SPI_WriteData(0xD0);
SPI_WriteComm(0xC901); SPI_WriteData(0x82);
SPI_WriteComm(0xC902); SPI_WriteData(0x50);
SPI_WriteComm(0xC903); SPI_WriteData(0x50);
SPI_WriteComm(0xC904); SPI_WriteData(0x50);

SPI_WriteComm(0x3500); SPI_WriteData(0x00); 

SPI_WriteComm(0x3600); SPI_WriteData(0x00); 

SPI_WriteComm(0x3A00); SPI_WriteData(0x55); 

SPI_WriteComm(0x1100);
Delay(20);
SPI_WriteComm(0x2900);
Delay(120);
 SPI_WriteComm(0x2C00);

#endif

#if 0

//LV2 Page 1 enable
SPI_WriteComm(0xF000); SPI_WriteData(0x55);
SPI_WriteComm(0xF001); SPI_WriteData(0xAA);
SPI_WriteComm(0xF002); SPI_WriteData(0x52);
SPI_WriteComm(0xF003); SPI_WriteData(0x08);
SPI_WriteComm(0xF004); SPI_WriteData(0x01); // page=1

//AVDD Set AVDD 5.2V
SPI_WriteComm(0xB000); SPI_WriteData(0x0D);
SPI_WriteComm(0xB001); SPI_WriteData(0x0D);
SPI_WriteComm(0xB002); SPI_WriteData(0x0D);

//AVDD ratio
SPI_WriteComm(0xB600); SPI_WriteData(0x44);
SPI_WriteComm(0xB601); SPI_WriteData(0x44);
SPI_WriteComm(0xB602); SPI_WriteData(0x44);

//AVEE  -5.2V
SPI_WriteComm(0xB100); SPI_WriteData(0x0D);
SPI_WriteComm(0xB101); SPI_WriteData(0x0D);
SPI_WriteComm(0xB102); SPI_WriteData(0x0D);

//AVEE ratio
SPI_WriteComm(0xB700); SPI_WriteData(0x34);
SPI_WriteComm(0xB701); SPI_WriteData(0x34);
SPI_WriteComm(0xB702); SPI_WriteData(0x34);

//VCL  -2.5V
SPI_WriteComm(0xB200); SPI_WriteData(0x00);
SPI_WriteComm(0xB201); SPI_WriteData(0x00);
SPI_WriteComm(0xB202); SPI_WriteData(0x00);

//VCL ratio
SPI_WriteComm(0xB800); SPI_WriteData(0x24);
SPI_WriteComm(0xB801); SPI_WriteData(0x24);
SPI_WriteComm(0xB802); SPI_WriteData(0x24);

//VGH 15V
SPI_WriteComm(0xBF00); SPI_WriteData(0x01);
SPI_WriteComm(0xB300); SPI_WriteData(0x0F);
SPI_WriteComm(0xB301); SPI_WriteData(0x0F);
SPI_WriteComm(0xB302); SPI_WriteData(0x0F);

//VGH ratio
SPI_WriteComm(0xB900); SPI_WriteData(0x34);
SPI_WriteComm(0xB901); SPI_WriteData(0x34);
SPI_WriteComm(0xB902); SPI_WriteData(0x34);

//VGL_REG
SPI_WriteComm(0xB500); SPI_WriteData(0x08);
SPI_WriteComm(0xB501); SPI_WriteData(0x08);
SPI_WriteComm(0xB502); SPI_WriteData(0x08);

//VGLX ratio
SPI_WriteComm(0xBA00); SPI_WriteData(0x34);
SPI_WriteComm(0xBA01); SPI_WriteData(0x34);
SPI_WriteComm(0xBA02); SPI_WriteData(0x34);

SPI_WriteComm(0xC200); SPI_WriteData(0x03);
SPI_WriteComm(0xC201); SPI_WriteData(0x00);
SPI_WriteComm(0xC202); SPI_WriteData(0x00);

//VGMP/VGSP 4.7V/0V
SPI_WriteComm(0xBC00); SPI_WriteData(0x00);
SPI_WriteComm(0xBC01); SPI_WriteData(0x78);
SPI_WriteComm(0xBC02); SPI_WriteData(0x00);

//VGMN/VGSN -4.7V/0V
SPI_WriteComm(0xBD00); SPI_WriteData(0x00);
SPI_WriteComm(0xBD01); SPI_WriteData(0x78);
SPI_WriteComm(0xBD02); SPI_WriteData(0x00);

//VCOM 1.525V
SPI_WriteComm(0xBE00); SPI_WriteData(0x00);
SPI_WriteComm(0xBE01); SPI_WriteData(0x5B);

//Gamma Setting
SPI_WriteComm(0xD100); SPI_WriteData(0x00);
SPI_WriteComm(0xD101); SPI_WriteData(0x1F);
SPI_WriteComm(0xD102); SPI_WriteData(0x00);
SPI_WriteComm(0xD103); SPI_WriteData(0x20);
SPI_WriteComm(0xD104); SPI_WriteData(0x00);
SPI_WriteComm(0xD105); SPI_WriteData(0x34);
SPI_WriteComm(0xD106); SPI_WriteData(0x00);
SPI_WriteComm(0xD107); SPI_WriteData(0x55);
SPI_WriteComm(0xD108); SPI_WriteData(0x00);
SPI_WriteComm(0xD109); SPI_WriteData(0x75);
SPI_WriteComm(0xD10A); SPI_WriteData(0x00);
SPI_WriteComm(0xD10B); SPI_WriteData(0xA9);
SPI_WriteComm(0xD10C); SPI_WriteData(0x00);
SPI_WriteComm(0xD10D); SPI_WriteData(0xCF);
SPI_WriteComm(0xD10E); SPI_WriteData(0x01);
SPI_WriteComm(0xD10F); SPI_WriteData(0x0B);
SPI_WriteComm(0xD110); SPI_WriteData(0x01);
SPI_WriteComm(0xD111); SPI_WriteData(0x33);
SPI_WriteComm(0xD112); SPI_WriteData(0x01);
SPI_WriteComm(0xD113); SPI_WriteData(0x71);
SPI_WriteComm(0xD114); SPI_WriteData(0x01);
SPI_WriteComm(0xD115); SPI_WriteData(0x9E);
SPI_WriteComm(0xD116); SPI_WriteData(0x01);
SPI_WriteComm(0xD117); SPI_WriteData(0xDE);
SPI_WriteComm(0xD118); SPI_WriteData(0x02);
SPI_WriteComm(0xD119); SPI_WriteData(0x0E);
SPI_WriteComm(0xD11A); SPI_WriteData(0x02);
SPI_WriteComm(0xD11B); SPI_WriteData(0x10);
SPI_WriteComm(0xD11C); SPI_WriteData(0x02);
SPI_WriteComm(0xD11D); SPI_WriteData(0x3C);
SPI_WriteComm(0xD11E); SPI_WriteData(0x02);
SPI_WriteComm(0xD11F); SPI_WriteData(0x67);
SPI_WriteComm(0xD120); SPI_WriteData(0x02);
SPI_WriteComm(0xD121); SPI_WriteData(0x7F);
SPI_WriteComm(0xD122); SPI_WriteData(0x02);
SPI_WriteComm(0xD123); SPI_WriteData(0x9C);
SPI_WriteComm(0xD124); SPI_WriteData(0x02);
SPI_WriteComm(0xD125); SPI_WriteData(0xAE);
SPI_WriteComm(0xD126); SPI_WriteData(0x02);
SPI_WriteComm(0xD127); SPI_WriteData(0xC5);
SPI_WriteComm(0xD128); SPI_WriteData(0x02);
SPI_WriteComm(0xD129); SPI_WriteData(0xD3);
SPI_WriteComm(0xD12A); SPI_WriteData(0x02);
SPI_WriteComm(0xD12B); SPI_WriteData(0xE6);
SPI_WriteComm(0xD12C); SPI_WriteData(0x02);
SPI_WriteComm(0xD12D); SPI_WriteData(0xF4);
SPI_WriteComm(0xD12E); SPI_WriteData(0x03);
SPI_WriteComm(0xD12F); SPI_WriteData(0x08);
SPI_WriteComm(0xD130); SPI_WriteData(0x03);
SPI_WriteComm(0xD131); SPI_WriteData(0x39);
SPI_WriteComm(0xD132); SPI_WriteData(0x03);
SPI_WriteComm(0xD133); SPI_WriteData(0xFA);

SPI_WriteComm(0xD200); SPI_WriteData(0x00);
SPI_WriteComm(0xD201); SPI_WriteData(0x1F);
SPI_WriteComm(0xD202); SPI_WriteData(0x00);
SPI_WriteComm(0xD203); SPI_WriteData(0x20);
SPI_WriteComm(0xD204); SPI_WriteData(0x00);
SPI_WriteComm(0xD205); SPI_WriteData(0x34);
SPI_WriteComm(0xD206); SPI_WriteData(0x00);
SPI_WriteComm(0xD207); SPI_WriteData(0x55);
SPI_WriteComm(0xD208); SPI_WriteData(0x00);
SPI_WriteComm(0xD209); SPI_WriteData(0x75);
SPI_WriteComm(0xD20A); SPI_WriteData(0x00);
SPI_WriteComm(0xD20B); SPI_WriteData(0xA9);
SPI_WriteComm(0xD20C); SPI_WriteData(0x00);
SPI_WriteComm(0xD20D); SPI_WriteData(0xCF);
SPI_WriteComm(0xD20E); SPI_WriteData(0x01);
SPI_WriteComm(0xD20F); SPI_WriteData(0x0B);
SPI_WriteComm(0xD210); SPI_WriteData(0x01);
SPI_WriteComm(0xD211); SPI_WriteData(0x33);
SPI_WriteComm(0xD212); SPI_WriteData(0x01);
SPI_WriteComm(0xD213); SPI_WriteData(0x71);
SPI_WriteComm(0xD214); SPI_WriteData(0x01);
SPI_WriteComm(0xD215); SPI_WriteData(0x9E);
SPI_WriteComm(0xD216); SPI_WriteData(0x01);
SPI_WriteComm(0xD217); SPI_WriteData(0xDE);
SPI_WriteComm(0xD218); SPI_WriteData(0x02);
SPI_WriteComm(0xD219); SPI_WriteData(0x0E);
SPI_WriteComm(0xD21A); SPI_WriteData(0x02);
SPI_WriteComm(0xD21B); SPI_WriteData(0x10);
SPI_WriteComm(0xD21C); SPI_WriteData(0x02);
SPI_WriteComm(0xD21D); SPI_WriteData(0x3C);
SPI_WriteComm(0xD21E); SPI_WriteData(0x02);
SPI_WriteComm(0xD21F); SPI_WriteData(0x67);
SPI_WriteComm(0xD220); SPI_WriteData(0x02);
SPI_WriteComm(0xD221); SPI_WriteData(0x7F);
SPI_WriteComm(0xD222); SPI_WriteData(0x02);
SPI_WriteComm(0xD223); SPI_WriteData(0x9C);
SPI_WriteComm(0xD224); SPI_WriteData(0x02);
SPI_WriteComm(0xD225); SPI_WriteData(0xAE);
SPI_WriteComm(0xD226); SPI_WriteData(0x02);
SPI_WriteComm(0xD227); SPI_WriteData(0xC5);
SPI_WriteComm(0xD228); SPI_WriteData(0x02);
SPI_WriteComm(0xD229); SPI_WriteData(0xD3);
SPI_WriteComm(0xD22A); SPI_WriteData(0x02);
SPI_WriteComm(0xD22B); SPI_WriteData(0xE6);
SPI_WriteComm(0xD22C); SPI_WriteData(0x02);
SPI_WriteComm(0xD22D); SPI_WriteData(0xF4);
SPI_WriteComm(0xD22E); SPI_WriteData(0x03);
SPI_WriteComm(0xD22F); SPI_WriteData(0x08);
SPI_WriteComm(0xD230); SPI_WriteData(0x03);
SPI_WriteComm(0xD231); SPI_WriteData(0x39);
SPI_WriteComm(0xD232); SPI_WriteData(0x03);
SPI_WriteComm(0xD233); SPI_WriteData(0xFA);

SPI_WriteComm(0xD300); SPI_WriteData(0x00);
SPI_WriteComm(0xD301); SPI_WriteData(0x1F);
SPI_WriteComm(0xD302); SPI_WriteData(0x00);
SPI_WriteComm(0xD303); SPI_WriteData(0x20);
SPI_WriteComm(0xD304); SPI_WriteData(0x00);
SPI_WriteComm(0xD305); SPI_WriteData(0x34);
SPI_WriteComm(0xD306); SPI_WriteData(0x00);
SPI_WriteComm(0xD307); SPI_WriteData(0x55);
SPI_WriteComm(0xD308); SPI_WriteData(0x00);
SPI_WriteComm(0xD309); SPI_WriteData(0x75);
SPI_WriteComm(0xD30A); SPI_WriteData(0x00);
SPI_WriteComm(0xD30B); SPI_WriteData(0xA9);
SPI_WriteComm(0xD30C); SPI_WriteData(0x00);
SPI_WriteComm(0xD30D); SPI_WriteData(0xCF);
SPI_WriteComm(0xD30E); SPI_WriteData(0x01);
SPI_WriteComm(0xD30F); SPI_WriteData(0x0B);
SPI_WriteComm(0xD310); SPI_WriteData(0x01);
SPI_WriteComm(0xD311); SPI_WriteData(0x33);
SPI_WriteComm(0xD312); SPI_WriteData(0x01);
SPI_WriteComm(0xD313); SPI_WriteData(0x71);
SPI_WriteComm(0xD314); SPI_WriteData(0x01);
SPI_WriteComm(0xD315); SPI_WriteData(0x9E);
SPI_WriteComm(0xD316); SPI_WriteData(0x01);
SPI_WriteComm(0xD317); SPI_WriteData(0xDE);
SPI_WriteComm(0xD318); SPI_WriteData(0x02);
SPI_WriteComm(0xD319); SPI_WriteData(0x0E);
SPI_WriteComm(0xD31A); SPI_WriteData(0x02);
SPI_WriteComm(0xD31B); SPI_WriteData(0x10);
SPI_WriteComm(0xD31C); SPI_WriteData(0x02);
SPI_WriteComm(0xD31D); SPI_WriteData(0x3C);
SPI_WriteComm(0xD31E); SPI_WriteData(0x02);
SPI_WriteComm(0xD31F); SPI_WriteData(0x67);
SPI_WriteComm(0xD320); SPI_WriteData(0x02);
SPI_WriteComm(0xD321); SPI_WriteData(0x7F);
SPI_WriteComm(0xD322); SPI_WriteData(0x02);
SPI_WriteComm(0xD323); SPI_WriteData(0x9C);
SPI_WriteComm(0xD324); SPI_WriteData(0x02);
SPI_WriteComm(0xD325); SPI_WriteData(0xAE);
SPI_WriteComm(0xD326); SPI_WriteData(0x02);
SPI_WriteComm(0xD327); SPI_WriteData(0xC5);
SPI_WriteComm(0xD328); SPI_WriteData(0x02);
SPI_WriteComm(0xD329); SPI_WriteData(0xD3);
SPI_WriteComm(0xD32A); SPI_WriteData(0x02);
SPI_WriteComm(0xD32B); SPI_WriteData(0xE6);
SPI_WriteComm(0xD32C); SPI_WriteData(0x02);
SPI_WriteComm(0xD32D); SPI_WriteData(0xF4);
SPI_WriteComm(0xD32E); SPI_WriteData(0x03);
SPI_WriteComm(0xD32F); SPI_WriteData(0x08);
SPI_WriteComm(0xD330); SPI_WriteData(0x03);
SPI_WriteComm(0xD331); SPI_WriteData(0x39);
SPI_WriteComm(0xD332); SPI_WriteData(0x03);
SPI_WriteComm(0xD333); SPI_WriteData(0xFA);

SPI_WriteComm(0xD400); SPI_WriteData(0x00);
SPI_WriteComm(0xD401); SPI_WriteData(0x1F);
SPI_WriteComm(0xD402); SPI_WriteData(0x00);
SPI_WriteComm(0xD403); SPI_WriteData(0x20);
SPI_WriteComm(0xD404); SPI_WriteData(0x00);
SPI_WriteComm(0xD405); SPI_WriteData(0x34);
SPI_WriteComm(0xD406); SPI_WriteData(0x00);
SPI_WriteComm(0xD407); SPI_WriteData(0x55);
SPI_WriteComm(0xD408); SPI_WriteData(0x00);
SPI_WriteComm(0xD409); SPI_WriteData(0x75);
SPI_WriteComm(0xD40A); SPI_WriteData(0x00);
SPI_WriteComm(0xD40B); SPI_WriteData(0xA9);
SPI_WriteComm(0xD40C); SPI_WriteData(0x00);
SPI_WriteComm(0xD40D); SPI_WriteData(0xCF);
SPI_WriteComm(0xD40E); SPI_WriteData(0x01);
SPI_WriteComm(0xD40F); SPI_WriteData(0x0B);
SPI_WriteComm(0xD410); SPI_WriteData(0x01);
SPI_WriteComm(0xD411); SPI_WriteData(0x33);
SPI_WriteComm(0xD412); SPI_WriteData(0x01);
SPI_WriteComm(0xD413); SPI_WriteData(0x71);
SPI_WriteComm(0xD414); SPI_WriteData(0x01);
SPI_WriteComm(0xD415); SPI_WriteData(0x9E);
SPI_WriteComm(0xD416); SPI_WriteData(0x01);
SPI_WriteComm(0xD417); SPI_WriteData(0xDE);
SPI_WriteComm(0xD418); SPI_WriteData(0x02);
SPI_WriteComm(0xD419); SPI_WriteData(0x0E);
SPI_WriteComm(0xD41A); SPI_WriteData(0x02);
SPI_WriteComm(0xD41B); SPI_WriteData(0x10);
SPI_WriteComm(0xD41C); SPI_WriteData(0x02);
SPI_WriteComm(0xD41D); SPI_WriteData(0x3C);
SPI_WriteComm(0xD41E); SPI_WriteData(0x02);
SPI_WriteComm(0xD41F); SPI_WriteData(0x67);
SPI_WriteComm(0xD420); SPI_WriteData(0x02);
SPI_WriteComm(0xD421); SPI_WriteData(0x7F);
SPI_WriteComm(0xD422); SPI_WriteData(0x02);
SPI_WriteComm(0xD423); SPI_WriteData(0x9C);
SPI_WriteComm(0xD424); SPI_WriteData(0x02);
SPI_WriteComm(0xD425); SPI_WriteData(0xAE);
SPI_WriteComm(0xD426); SPI_WriteData(0x02);
SPI_WriteComm(0xD427); SPI_WriteData(0xC5);
SPI_WriteComm(0xD428); SPI_WriteData(0x02);
SPI_WriteComm(0xD429); SPI_WriteData(0xD3);
SPI_WriteComm(0xD42A); SPI_WriteData(0x02);
SPI_WriteComm(0xD42B); SPI_WriteData(0xE6);
SPI_WriteComm(0xD42C); SPI_WriteData(0x02);
SPI_WriteComm(0xD42D); SPI_WriteData(0xF4);
SPI_WriteComm(0xD42E); SPI_WriteData(0x03);
SPI_WriteComm(0xD42F); SPI_WriteData(0x08);
SPI_WriteComm(0xD430); SPI_WriteData(0x03);
SPI_WriteComm(0xD431); SPI_WriteData(0x39);
SPI_WriteComm(0xD432); SPI_WriteData(0x03);
SPI_WriteComm(0xD433); SPI_WriteData(0xFA);

SPI_WriteComm(0xD500); SPI_WriteData(0x00);
SPI_WriteComm(0xD501); SPI_WriteData(0x1F);
SPI_WriteComm(0xD502); SPI_WriteData(0x00);
SPI_WriteComm(0xD503); SPI_WriteData(0x20);
SPI_WriteComm(0xD504); SPI_WriteData(0x00);
SPI_WriteComm(0xD505); SPI_WriteData(0x34);
SPI_WriteComm(0xD506); SPI_WriteData(0x00);
SPI_WriteComm(0xD507); SPI_WriteData(0x55);
SPI_WriteComm(0xD508); SPI_WriteData(0x00);
SPI_WriteComm(0xD509); SPI_WriteData(0x75);
SPI_WriteComm(0xD50A); SPI_WriteData(0x00);
SPI_WriteComm(0xD50B); SPI_WriteData(0xA9);
SPI_WriteComm(0xD50C); SPI_WriteData(0x00);
SPI_WriteComm(0xD50D); SPI_WriteData(0xCF);
SPI_WriteComm(0xD50E); SPI_WriteData(0x01);
SPI_WriteComm(0xD50F); SPI_WriteData(0x0B);
SPI_WriteComm(0xD510); SPI_WriteData(0x01);
SPI_WriteComm(0xD511); SPI_WriteData(0x33);
SPI_WriteComm(0xD512); SPI_WriteData(0x01);
SPI_WriteComm(0xD513); SPI_WriteData(0x71);
SPI_WriteComm(0xD514); SPI_WriteData(0x01);
SPI_WriteComm(0xD515); SPI_WriteData(0x9E);
SPI_WriteComm(0xD516); SPI_WriteData(0x01);
SPI_WriteComm(0xD517); SPI_WriteData(0xDE);
SPI_WriteComm(0xD518); SPI_WriteData(0x02);
SPI_WriteComm(0xD519); SPI_WriteData(0x0E);
SPI_WriteComm(0xD51A); SPI_WriteData(0x02);
SPI_WriteComm(0xD51B); SPI_WriteData(0x10);
SPI_WriteComm(0xD51C); SPI_WriteData(0x02);
SPI_WriteComm(0xD51D); SPI_WriteData(0x3C);
SPI_WriteComm(0xD51E); SPI_WriteData(0x02);
SPI_WriteComm(0xD51F); SPI_WriteData(0x67);
SPI_WriteComm(0xD520); SPI_WriteData(0x02);
SPI_WriteComm(0xD521); SPI_WriteData(0x7F);
SPI_WriteComm(0xD522); SPI_WriteData(0x02);
SPI_WriteComm(0xD523); SPI_WriteData(0x9C);
SPI_WriteComm(0xD524); SPI_WriteData(0x02);
SPI_WriteComm(0xD525); SPI_WriteData(0xAE);
SPI_WriteComm(0xD526); SPI_WriteData(0x02);
SPI_WriteComm(0xD527); SPI_WriteData(0xC5);
SPI_WriteComm(0xD528); SPI_WriteData(0x02);
SPI_WriteComm(0xD529); SPI_WriteData(0xD3);
SPI_WriteComm(0xD52A); SPI_WriteData(0x02);
SPI_WriteComm(0xD52B); SPI_WriteData(0xE6);
SPI_WriteComm(0xD52C); SPI_WriteData(0x02);
SPI_WriteComm(0xD52D); SPI_WriteData(0xF4);
SPI_WriteComm(0xD52E); SPI_WriteData(0x03);
SPI_WriteComm(0xD52F); SPI_WriteData(0x08);
SPI_WriteComm(0xD530); SPI_WriteData(0x03);
SPI_WriteComm(0xD531); SPI_WriteData(0x39);
SPI_WriteComm(0xD532); SPI_WriteData(0x03);
SPI_WriteComm(0xD533); SPI_WriteData(0xFA);

SPI_WriteComm(0xD600); SPI_WriteData(0x00);
SPI_WriteComm(0xD601); SPI_WriteData(0x1F);
SPI_WriteComm(0xD602); SPI_WriteData(0x00);
SPI_WriteComm(0xD603); SPI_WriteData(0x20);
SPI_WriteComm(0xD604); SPI_WriteData(0x00);
SPI_WriteComm(0xD605); SPI_WriteData(0x34);
SPI_WriteComm(0xD606); SPI_WriteData(0x00);
SPI_WriteComm(0xD607); SPI_WriteData(0x55);
SPI_WriteComm(0xD608); SPI_WriteData(0x00);
SPI_WriteComm(0xD609); SPI_WriteData(0x75);
SPI_WriteComm(0xD60A); SPI_WriteData(0x00);
SPI_WriteComm(0xD60B); SPI_WriteData(0xA9);
SPI_WriteComm(0xD60C); SPI_WriteData(0x00);
SPI_WriteComm(0xD60D); SPI_WriteData(0xCF);
SPI_WriteComm(0xD60E); SPI_WriteData(0x01);
SPI_WriteComm(0xD60F); SPI_WriteData(0x0B);
SPI_WriteComm(0xD610); SPI_WriteData(0x01);
SPI_WriteComm(0xD611); SPI_WriteData(0x33);
SPI_WriteComm(0xD612); SPI_WriteData(0x01);
SPI_WriteComm(0xD613); SPI_WriteData(0x71);
SPI_WriteComm(0xD614); SPI_WriteData(0x01);
SPI_WriteComm(0xD615); SPI_WriteData(0x9E);
SPI_WriteComm(0xD616); SPI_WriteData(0x01);
SPI_WriteComm(0xD617); SPI_WriteData(0xDE);
SPI_WriteComm(0xD618); SPI_WriteData(0x02);
SPI_WriteComm(0xD619); SPI_WriteData(0x0E);
SPI_WriteComm(0xD61A); SPI_WriteData(0x02);
SPI_WriteComm(0xD61B); SPI_WriteData(0x10);
SPI_WriteComm(0xD61C); SPI_WriteData(0x02);
SPI_WriteComm(0xD61D); SPI_WriteData(0x3C);
SPI_WriteComm(0xD61E); SPI_WriteData(0x02);
SPI_WriteComm(0xD61F); SPI_WriteData(0x67);
SPI_WriteComm(0xD620); SPI_WriteData(0x02);
SPI_WriteComm(0xD621); SPI_WriteData(0x7F);
SPI_WriteComm(0xD622); SPI_WriteData(0x02);
SPI_WriteComm(0xD623); SPI_WriteData(0x9C);
SPI_WriteComm(0xD624); SPI_WriteData(0x02);
SPI_WriteComm(0xD625); SPI_WriteData(0xAE);
SPI_WriteComm(0xD626); SPI_WriteData(0x02);
SPI_WriteComm(0xD627); SPI_WriteData(0xC5);
SPI_WriteComm(0xD628); SPI_WriteData(0x02);
SPI_WriteComm(0xD629); SPI_WriteData(0xD3);
SPI_WriteComm(0xD62A); SPI_WriteData(0x02);
SPI_WriteComm(0xD62B); SPI_WriteData(0xE6);
SPI_WriteComm(0xD62C); SPI_WriteData(0x02);
SPI_WriteComm(0xD62D); SPI_WriteData(0xF4);
SPI_WriteComm(0xD62E); SPI_WriteData(0x03);
SPI_WriteComm(0xD62F); SPI_WriteData(0x08);
SPI_WriteComm(0xD630); SPI_WriteData(0x03);
SPI_WriteComm(0xD631); SPI_WriteData(0x39);
SPI_WriteComm(0xD632); SPI_WriteData(0x03);
SPI_WriteComm(0xD633); SPI_WriteData(0xFA);

//LV2 Page 0 enable
SPI_WriteComm(0xF000); SPI_WriteData(0x55);
SPI_WriteComm(0xF001); SPI_WriteData(0xAA);
SPI_WriteComm(0xF002); SPI_WriteData(0x52);
SPI_WriteComm(0xF003); SPI_WriteData(0x08);
SPI_WriteComm(0xF004); SPI_WriteData(0x00);  // page=0

//Resolution range
SPI_WriteComm(0xB500); SPI_WriteData(0x6d);

//Display control
SPI_WriteComm(0xB100); SPI_WriteData(0xCC);
SPI_WriteComm(0xB101); SPI_WriteData(0x00);

//Source hold time
SPI_WriteComm(0xB600); SPI_WriteData(0x05);

//Gate EQ control
SPI_WriteComm(0xB700); SPI_WriteData(0x70);
SPI_WriteComm(0xB701); SPI_WriteData(0x70);

//Source EQ control (Mode 2)
SPI_WriteComm(0xB800); SPI_WriteData(0x01);
SPI_WriteComm(0xB801); SPI_WriteData(0x03);
SPI_WriteComm(0xB802); SPI_WriteData(0x03);
SPI_WriteComm(0xB803); SPI_WriteData(0x03);

//Inversion mode  (Column)
SPI_WriteComm(0xBC00); SPI_WriteData(0x00);
SPI_WriteComm(0xBC01); SPI_WriteData(0x00);
SPI_WriteComm(0xBC02); SPI_WriteData(0x00);

//Frame rate
SPI_WriteComm(0xBD00); SPI_WriteData(0x01);
SPI_WriteComm(0xBD01); SPI_WriteData(0x84);
SPI_WriteComm(0xBD02); SPI_WriteData(0x1C);
SPI_WriteComm(0xBD03); SPI_WriteData(0x1C);
SPI_WriteComm(0xBD04); SPI_WriteData(0x00);

//Timing control 8phase dual side/4H/4delay/RST_EN
SPI_WriteComm(0xC900); SPI_WriteData(0xD0);
SPI_WriteComm(0xC901); SPI_WriteData(0x82);
SPI_WriteComm(0xC902); SPI_WriteData(0x50);
SPI_WriteComm(0xC903); SPI_WriteData(0x50);
SPI_WriteComm(0xC904); SPI_WriteData(0x50);

SPI_WriteComm(0x3500); SPI_WriteData(0x00); 

SPI_WriteComm(0x3600); SPI_WriteData(0x00); 

SPI_WriteComm(0x3A00); SPI_WriteData(0x55); 

SPI_WriteComm(0x1100);
Delay(20);
SPI_WriteComm(0x2900);
Delay(120);
 SPI_WriteComm(0x2C00);
#endif

#if 0
				//PAGE1
	SPI_WriteComm(0xF000);    SPI_WriteData(0x0055);
	SPI_WriteComm(0xF001);    SPI_WriteData(0x00AA);
	SPI_WriteComm(0xF002);    SPI_WriteData(0x0052);
	SPI_WriteComm(0xF003);    SPI_WriteData(0x0008);
	SPI_WriteComm(0xF004);    SPI_WriteData(0x0001);

//Set AVDD 5.2V
	SPI_WriteComm(0xB000);    SPI_WriteData(0x000D);
	SPI_WriteComm(0xB001);    SPI_WriteData(0x000D);
	SPI_WriteComm(0xB002);    SPI_WriteData(0x000D);

//Set AVEE 5.2V
	SPI_WriteComm(0xB100);    SPI_WriteData(0x000D);
	SPI_WriteComm(0xB101);    SPI_WriteData(0x000D);
	SPI_WriteComm(0xB102);    SPI_WriteData(0x000D);

//Set VCL -2.5V
	SPI_WriteComm(0xB200);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xB201);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xB202);    SPI_WriteData(0x0000);				

//Set AVDD Ratio
	SPI_WriteComm(0xB600);    SPI_WriteData(0x0044);
	SPI_WriteComm(0xB601);    SPI_WriteData(0x0044);
	SPI_WriteComm(0xB602);    SPI_WriteData(0x0044);

//Set AVEE Ratio
	SPI_WriteComm(0xB700);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB701);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB702);    SPI_WriteData(0x0034);

//Set VCL -2.5V
	SPI_WriteComm(0xB800);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB801);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB802);    SPI_WriteData(0x0034);

//Control VGH booster voltage rang
	SPI_WriteComm(0xBF00);    SPI_WriteData(0x0001); //VGH:7~18V	

//VGH=15V(1V/step)	Free pump
	SPI_WriteComm(0xB300);    SPI_WriteData(0x000f);		//08
	SPI_WriteComm(0xB301);    SPI_WriteData(0x000f);		//08
	SPI_WriteComm(0xB302);    SPI_WriteData(0x000f);		//08

//VGH Ratio
	SPI_WriteComm(0xB900);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB901);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB902);    SPI_WriteData(0x0034);

//VGL_REG=-10(1V/step)
	SPI_WriteComm(0xB500);    SPI_WriteData(0x0008);
	SPI_WriteComm(0xB501);    SPI_WriteData(0x0008);
	SPI_WriteComm(0xB502);    SPI_WriteData(0x0008);

  SPI_WriteComm(0xC200);    SPI_WriteData(0x0003);

//VGLX Ratio
	SPI_WriteComm(0xBA00);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xBA01);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xBA02);    SPI_WriteData(0x0034);

//VGMP/VGSP=4.5V/0V
	SPI_WriteComm(0xBC00);    SPI_WriteData(0x0000);		//00
	SPI_WriteComm(0xBC01);    SPI_WriteData(0x0078);		//C8 =5.5V/90=4.8V
	SPI_WriteComm(0xBC02);    SPI_WriteData(0x0000);		//01

//VGMN/VGSN=-4.5V/0V
	SPI_WriteComm(0xBD00);    SPI_WriteData(0x0000); //00
	SPI_WriteComm(0xBD01);    SPI_WriteData(0x0078); //90
	SPI_WriteComm(0xBD02);    SPI_WriteData(0x0000);

//Vcom=-1.4V(12.5mV/step)
  SPI_WriteComm(0xBE00);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xBE01);    SPI_WriteData(0x0064); //HSD:64;Novatek:50=-1.0V, 80  5f

//Gamma (R+)
	SPI_WriteComm(0xD100);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD101);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD102);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD103);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD104);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD105);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD106);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD107);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD108);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD109);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD10A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD10B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD10C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD10D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD10E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD10F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD110);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD111);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD112);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD113);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD114);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD115);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD116);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD117);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD118);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD119);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD11A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD11B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD11C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD11D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD11E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD11F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD120);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD121);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD122);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD123);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD124);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD125);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD126);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD127);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD128);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD129);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD12A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD12B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD12C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD12D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD12E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD12F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD130);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD131);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD132);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD133);    SPI_WriteData(0x006D);

//Gamma (G+)
	SPI_WriteComm(0xD200);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD201);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD202);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD203);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD204);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD205);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD206);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD207);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD208);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD209);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD20A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD20B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD20C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD20D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD20E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD20F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD210);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD211);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD212);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD213);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD214);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD215);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD216);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD217);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD218);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD219);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD21A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD21B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD21C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD21D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD21E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD21F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD220);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD221);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD222);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD223);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD224);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD225);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD226);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD227);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD228);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD229);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD22A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD22B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD22C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD22D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD22E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD22F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD230);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD231);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD232);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD233);    SPI_WriteData(0x006D);

//Gamma (B+)
	SPI_WriteComm(0xD300);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD301);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD302);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD303);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD304);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD305);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD306);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD307);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD308);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD309);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD30A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD30B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD30C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD30D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD30E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD30F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD310);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD311);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD312);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD313);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD314);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD315);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD316);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD317);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD318);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD319);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD31A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD31B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD31C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD31D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD31E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD31F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD320);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD321);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD322);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD323);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD324);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD325);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD326);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD327);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD328);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD329);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD32A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD32B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD32C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD32D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD32E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD32F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD330);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD331);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD332);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD333);    SPI_WriteData(0x006D);

//Gamma (R-)
	SPI_WriteComm(0xD400);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD401);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD402);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD403);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD404);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD405);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD406);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD407);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD408);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD409);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD40A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD40B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD40C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD40D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD40E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD40F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD410);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD411);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD412);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD413);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD414);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD415);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD416);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD417);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD418);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD419);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD41A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD41B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD41C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD41D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD41E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD41F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD420);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD421);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD422);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD423);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD424);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD425);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD426);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD427);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD428);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD429);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD42A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD42B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD42C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD42D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD42E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD42F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD430);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD431);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD432);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD433);    SPI_WriteData(0x006D);

//Gamma (G-)
	SPI_WriteComm(0xD500);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD501);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD502);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD503);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD504);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD505);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD506);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD507);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD508);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD509);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD50A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD50B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD50C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD50D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD50E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD50F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD510);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD511);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD512);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD513);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD514);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD515);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD516);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD517);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD518);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD519);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD51A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD51B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD51C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD51D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD51E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD51F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD520);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD521);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD522);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD523);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD524);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD525);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD526);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD527);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD528);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD529);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD52A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD52B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD52C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD52D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD52E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD52F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD530);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD531);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD532);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD533);    SPI_WriteData(0x006D);

//Gamma (B-)
	SPI_WriteComm(0xD600);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD601);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD602);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD603);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD604);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD605);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD606);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD607);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD608);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD609);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD60A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD60B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD60C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD60D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD60E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD60F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD610);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD611);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD612);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD613);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD614);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD615);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD616);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD617);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD618);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD619);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD61A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD61B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD61C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD61D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD61E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD61F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD620);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD621);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD622);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD623);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD624);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD625);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD626);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD627);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD628);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD629);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD62A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD62B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD62C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD62D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD62E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD62F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD630);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD631);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD632);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD633);    SPI_WriteData(0x006D);

//PAGE0
	SPI_WriteComm(0xF000);    SPI_WriteData(0x0055);
  SPI_WriteComm(0xF001);    SPI_WriteData(0x00AA);
	SPI_WriteComm(0xF002);    SPI_WriteData(0x0052);
	SPI_WriteComm(0xF003);    SPI_WriteData(0x0008);
	SPI_WriteComm(0xF004);    SPI_WriteData(0x0000); 

//480x800
  SPI_WriteComm(0xB500);    SPI_WriteData(0x006d);

//SPI_WriteComm(0x2C00);    SPI_WriteData(0x0006); //8BIT 6-6-6?

//Dispay control
	SPI_WriteComm(0xB100);    SPI_WriteData(0x00CC);
  SPI_WriteComm(0xB101);    SPI_WriteData(0x0000); // S1->S1440:00;S1440->S1:02

//Source hold time (Nova non-used)
	SPI_WriteComm(0xB600);    SPI_WriteData(0x0005);

//Gate EQ control	 (Nova non-used)
	SPI_WriteComm(0xB700);    SPI_WriteData(0x0077);  //HSD:70;Nova:77
	SPI_WriteComm(0xB701);    SPI_WriteData(0x0077);	//HSD:70;Nova:77

//Source EQ control (Nova non-used)
	SPI_WriteComm(0xB800);    SPI_WriteData(0x0001);
  SPI_WriteComm(0xB801);    SPI_WriteData(0x0003);	//HSD:05;Nova:07
	SPI_WriteComm(0xB802);    SPI_WriteData(0x0003);	//HSD:05;Nova:07
	SPI_WriteComm(0xB803);    SPI_WriteData(0x0003);	//HSD:05;Nova:07

//Inversion mode: column
	SPI_WriteComm(0xBC00);    SPI_WriteData(0x0002);	//00: column
	SPI_WriteComm(0xBC01);    SPI_WriteData(0x0000);	//01:1dot
	SPI_WriteComm(0xBC02);    SPI_WriteData(0x0000); 

//Frame rate	(Nova non-used)
	SPI_WriteComm(0xBD00);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xBD01);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xBD02);    SPI_WriteData(0x001c); //HSD:06;Nova:1C
	SPI_WriteComm(0xBD03);    SPI_WriteData(0x001c); //HSD:04;Nova:1C
  SPI_WriteComm(0xBD04);    SPI_WriteData(0x0000);

//LGD timing control(4H/4-Delay)
	SPI_WriteComm(0xC900);    SPI_WriteData(0x00D0);	//3H:0x50;4H:0xD0	 //D
	SPI_WriteComm(0xC901);    SPI_WriteData(0x0002);  //HSD:05;Nova:02
	SPI_WriteComm(0xC902);    SPI_WriteData(0x0050);	//HSD:05;Nova:50
	SPI_WriteComm(0xC903);    SPI_WriteData(0x0050);	//HSD:05;Nova:50	;STV delay time
  SPI_WriteComm(0xC904);    SPI_WriteData(0x0050);	//HSD:05;Nova:50	;CLK delay time

	SPI_WriteComm(0x3600);    SPI_WriteData(0x0000);
	SPI_WriteComm(0x3500);    SPI_WriteData(0x0000);

	SPI_WriteComm(0xFF00);    SPI_WriteData(0x00AA);
  SPI_WriteComm(0xFF01);    SPI_WriteData(0x0055);
	SPI_WriteComm(0xFF02);    SPI_WriteData(0x0025);
	SPI_WriteComm(0xFF03);    SPI_WriteData(0x0001);

	SPI_WriteComm(0xFC00);    SPI_WriteData(0x0016);
	SPI_WriteComm(0xFC01);    SPI_WriteData(0x00A2);
	SPI_WriteComm(0xFC02);    SPI_WriteData(0x0026);
	SPI_WriteComm(0x3A00);    SPI_WriteData(0x0006);

	SPI_WriteComm(0x3A00);    SPI_WriteData(0x0077);
//Sleep out
	SPI_WriteComm(0x1100);
	Delay(160);

//Display on
	SPI_WriteComm(0x2900);
#endif
#if 0
				//PAGE1
	SPI_WriteComm(0xF000);    SPI_WriteData(0x0055);
	SPI_WriteComm(0xF001);    SPI_WriteData(0x00AA);
	SPI_WriteComm(0xF002);    SPI_WriteData(0x0052);
	SPI_WriteComm(0xF003);    SPI_WriteData(0x0008);
	SPI_WriteComm(0xF004);    SPI_WriteData(0x0001);

//Set AVDD 5.2V
	SPI_WriteComm(0xB000);    SPI_WriteData(0x000D);
	SPI_WriteComm(0xB001);    SPI_WriteData(0x000D);
	SPI_WriteComm(0xB002);    SPI_WriteData(0x000D);

//Set AVEE 5.2V
	SPI_WriteComm(0xB100);    SPI_WriteData(0x000D);
	SPI_WriteComm(0xB101);    SPI_WriteData(0x000D);
	SPI_WriteComm(0xB102);    SPI_WriteData(0x000D);

//Set VCL -2.5V
	SPI_WriteComm(0xB200);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xB201);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xB202);    SPI_WriteData(0x0000);				

//Set AVDD Ratio
	SPI_WriteComm(0xB600);    SPI_WriteData(0x0044);
	SPI_WriteComm(0xB601);    SPI_WriteData(0x0044);
	SPI_WriteComm(0xB602);    SPI_WriteData(0x0044);

//Set AVEE Ratio
	SPI_WriteComm(0xB700);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB701);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB702);    SPI_WriteData(0x0034);

//Set VCL -2.5V
	SPI_WriteComm(0xB800);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB801);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB802);    SPI_WriteData(0x0034);

//Control VGH booster voltage rang
	SPI_WriteComm(0xBF00);    SPI_WriteData(0x0001); //VGH:7~18V	

//VGH=15V(1V/step)	Free pump
	SPI_WriteComm(0xB300);    SPI_WriteData(0x000f);		//08
	SPI_WriteComm(0xB301);    SPI_WriteData(0x000f);		//08
	SPI_WriteComm(0xB302);    SPI_WriteData(0x000f);		//08

//VGH Ratio
	SPI_WriteComm(0xB900);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB901);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xB902);    SPI_WriteData(0x0034);

//VGL_REG=-10(1V/step)
	SPI_WriteComm(0xB500);    SPI_WriteData(0x0008);
	SPI_WriteComm(0xB501);    SPI_WriteData(0x0008);
	SPI_WriteComm(0xB502);    SPI_WriteData(0x0008);

  SPI_WriteComm(0xC200);    SPI_WriteData(0x0003);

//VGLX Ratio
	SPI_WriteComm(0xBA00);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xBA01);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xBA02);    SPI_WriteData(0x0034);

//VGMP/VGSP=4.5V/0V
	SPI_WriteComm(0xBC00);    SPI_WriteData(0x0000);		//00
	SPI_WriteComm(0xBC01);    SPI_WriteData(0x0078);		//C8 =5.5V/90=4.8V
	SPI_WriteComm(0xBC02);    SPI_WriteData(0x0000);		//01

//VGMN/VGSN=-4.5V/0V
	SPI_WriteComm(0xBD00);    SPI_WriteData(0x0000); //00
	SPI_WriteComm(0xBD01);    SPI_WriteData(0x0078); //90
	SPI_WriteComm(0xBD02);    SPI_WriteData(0x0000);

//Vcom=-1.4V(12.5mV/step)
  SPI_WriteComm(0xBE00);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xBE01);    SPI_WriteData(0x0064); //HSD:64;Novatek:50=-1.0V, 80  5f

//Gamma (R+)
	SPI_WriteComm(0xD100);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD101);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD102);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD103);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD104);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD105);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD106);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD107);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD108);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD109);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD10A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD10B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD10C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD10D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD10E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD10F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD110);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD111);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD112);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD113);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD114);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD115);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD116);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD117);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD118);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD119);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD11A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD11B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD11C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD11D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD11E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD11F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD120);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD121);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD122);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD123);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD124);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD125);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD126);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD127);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD128);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD129);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD12A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD12B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD12C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD12D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD12E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD12F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD130);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD131);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD132);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD133);    SPI_WriteData(0x006D);

//Gamma (G+)
	SPI_WriteComm(0xD200);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD201);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD202);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD203);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD204);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD205);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD206);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD207);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD208);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD209);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD20A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD20B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD20C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD20D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD20E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD20F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD210);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD211);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD212);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD213);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD214);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD215);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD216);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD217);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD218);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD219);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD21A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD21B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD21C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD21D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD21E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD21F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD220);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD221);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD222);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD223);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD224);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD225);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD226);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD227);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD228);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD229);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD22A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD22B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD22C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD22D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD22E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD22F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD230);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD231);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD232);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD233);    SPI_WriteData(0x006D);

//Gamma (B+)
	SPI_WriteComm(0xD300);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD301);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD302);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD303);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD304);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD305);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD306);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD307);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD308);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD309);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD30A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD30B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD30C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD30D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD30E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD30F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD310);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD311);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD312);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD313);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD314);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD315);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD316);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD317);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD318);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD319);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD31A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD31B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD31C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD31D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD31E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD31F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD320);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD321);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD322);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD323);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD324);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD325);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD326);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD327);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD328);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD329);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD32A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD32B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD32C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD32D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD32E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD32F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD330);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD331);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD332);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD333);    SPI_WriteData(0x006D);

//Gamma (R-)
	SPI_WriteComm(0xD400);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD401);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD402);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD403);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD404);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD405);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD406);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD407);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD408);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD409);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD40A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD40B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD40C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD40D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD40E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD40F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD410);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD411);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD412);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD413);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD414);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD415);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD416);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD417);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD418);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD419);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD41A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD41B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD41C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD41D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD41E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD41F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD420);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD421);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD422);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD423);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD424);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD425);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD426);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD427);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD428);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD429);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD42A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD42B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD42C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD42D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD42E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD42F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD430);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD431);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD432);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD433);    SPI_WriteData(0x006D);

//Gamma (G-)
	SPI_WriteComm(0xD500);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD501);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD502);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD503);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD504);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD505);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD506);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD507);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD508);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD509);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD50A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD50B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD50C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD50D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD50E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD50F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD510);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD511);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD512);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD513);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD514);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD515);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD516);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD517);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD518);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD519);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD51A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD51B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD51C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD51D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD51E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD51F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD520);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD521);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD522);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD523);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD524);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD525);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD526);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD527);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD528);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD529);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD52A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD52B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD52C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD52D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD52E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD52F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD530);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD531);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD532);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD533);    SPI_WriteData(0x006D);

//Gamma (B-)
	SPI_WriteComm(0xD600);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD601);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD602);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD603);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD604);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD605);    SPI_WriteData(0x003A);
	SPI_WriteComm(0xD606);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD607);    SPI_WriteData(0x004A);
	SPI_WriteComm(0xD608);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD609);    SPI_WriteData(0x005C);
	SPI_WriteComm(0xD60A);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD60B);    SPI_WriteData(0x0081);
	SPI_WriteComm(0xD60C);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD60D);    SPI_WriteData(0x00A6);
	SPI_WriteComm(0xD60E);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD60F);    SPI_WriteData(0x00E5);
	SPI_WriteComm(0xD610);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD611);    SPI_WriteData(0x0013);
	SPI_WriteComm(0xD612);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD613);    SPI_WriteData(0x0054);
	SPI_WriteComm(0xD614);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD615);    SPI_WriteData(0x0082);
	SPI_WriteComm(0xD616);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD617);    SPI_WriteData(0x00CA);
	SPI_WriteComm(0xD618);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD619);    SPI_WriteData(0x0000);
	SPI_WriteComm(0xD61A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD61B);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xD61C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD61D);    SPI_WriteData(0x0034);
	SPI_WriteComm(0xD61E);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD61F);    SPI_WriteData(0x0067);
	SPI_WriteComm(0xD620);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD621);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xD622);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD623);    SPI_WriteData(0x00A4);
	SPI_WriteComm(0xD624);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD625);    SPI_WriteData(0x00B7);
	SPI_WriteComm(0xD626);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD627);    SPI_WriteData(0x00CF);
	SPI_WriteComm(0xD628);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD629);    SPI_WriteData(0x00DE);
	SPI_WriteComm(0xD62A);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD62B);    SPI_WriteData(0x00F2);
	SPI_WriteComm(0xD62C);    SPI_WriteData(0x0002);
	SPI_WriteComm(0xD62D);    SPI_WriteData(0x00FE);
	SPI_WriteComm(0xD62E);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD62F);    SPI_WriteData(0x0010);
	SPI_WriteComm(0xD630);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD631);    SPI_WriteData(0x0033);
	SPI_WriteComm(0xD632);    SPI_WriteData(0x0003);
	SPI_WriteComm(0xD633);    SPI_WriteData(0x006D);

//PAGE0
	SPI_WriteComm(0xF000);    SPI_WriteData(0x0055);
  SPI_WriteComm(0xF001);    SPI_WriteData(0x00AA);
	SPI_WriteComm(0xF002);    SPI_WriteData(0x0052);
	SPI_WriteComm(0xF003);    SPI_WriteData(0x0008);
	SPI_WriteComm(0xF004);    SPI_WriteData(0x0000); 

//480x800
  SPI_WriteComm(0xB500);    SPI_WriteData(0x0050);

//SPI_WriteComm(0x2C00);    SPI_WriteData(0x0006); //8BIT 6-6-6?

//Dispay control
	SPI_WriteComm(0xB100);    SPI_WriteData(0x00CC);
    SPI_WriteComm(0xB101);    SPI_WriteData(0x0000); // S1->S1440:00;S1440->S1:02

//Source hold time (Nova non-used)
	SPI_WriteComm(0xB600);    SPI_WriteData(0x0005);

SPI_WriteComm(0xB500);    SPI_WriteData(0x006d);

//Gate EQ control	 (Nova non-used)
	SPI_WriteComm(0xB700);    SPI_WriteData(0x0077);  //HSD:70;Nova:77
	SPI_WriteComm(0xB701);    SPI_WriteData(0x0077);	//HSD:70;Nova:77

//Source EQ control (Nova non-used)
	SPI_WriteComm(0xB800);    SPI_WriteData(0x0001);
    SPI_WriteComm(0xB801);    SPI_WriteData(0x0003);	//HSD:05;Nova:07
	SPI_WriteComm(0xB802);    SPI_WriteData(0x0003);	//HSD:05;Nova:07
	SPI_WriteComm(0xB803);    SPI_WriteData(0x0003);	//HSD:05;Nova:07

//Inversion mode: column
	SPI_WriteComm(0xBC00);    SPI_WriteData(0x0002);	//00: column
	SPI_WriteComm(0xBC01);    SPI_WriteData(0x0000);	//01:1dot
	SPI_WriteComm(0xBC02);    SPI_WriteData(0x0000); 

//Frame rate	(Nova non-used)
	SPI_WriteComm(0xBD00);    SPI_WriteData(0x0001);
	SPI_WriteComm(0xBD01);    SPI_WriteData(0x0084);
	SPI_WriteComm(0xBD02);    SPI_WriteData(0x001c); //HSD:06;Nova:1C
	SPI_WriteComm(0xBD03);    SPI_WriteData(0x001c); //HSD:04;Nova:1C
    SPI_WriteComm(0xBD04);    SPI_WriteData(0x0000);

//LGD timing control(4H/4-Delay)
	SPI_WriteComm(0xC900);    SPI_WriteData(0x00D0);	//3H:0x50;4H:0xD0	 //D
	SPI_WriteComm(0xC901);    SPI_WriteData(0x0002);  //HSD:05;Nova:02
	SPI_WriteComm(0xC902);    SPI_WriteData(0x0050);	//HSD:05;Nova:50
	SPI_WriteComm(0xC903);    SPI_WriteData(0x0050);	//HSD:05;Nova:50	;STV delay time
    SPI_WriteComm(0xC904);    SPI_WriteData(0x0050);	//HSD:05;Nova:50	;CLK delay time

	SPI_WriteComm(0x3600);    SPI_WriteData(0x0000);
	SPI_WriteComm(0x3500);    SPI_WriteData(0x0000);

	SPI_WriteComm(0xFF00);    SPI_WriteData(0x00AA);
    SPI_WriteComm(0xFF01);    SPI_WriteData(0x0055);
	SPI_WriteComm(0xFF02);    SPI_WriteData(0x0025);
	SPI_WriteComm(0xFF03);    SPI_WriteData(0x0001);

	SPI_WriteComm(0xFC00);    SPI_WriteData(0x0016);
	SPI_WriteComm(0xFC01);    SPI_WriteData(0x00A2);
	SPI_WriteComm(0xFC02);    SPI_WriteData(0x0026);
	SPI_WriteComm(0x3A00);    SPI_WriteData(0x0006);

	SPI_WriteComm(0x3A00);    SPI_WriteData(0x0077);
//Sleep out
	SPI_WriteComm(0x1100);
	Delay(160);

//Display on
	SPI_WriteComm(0x2900);
#endif

}
void led_blinky()
{
   while(1)
   {
    LED_1_Set();
    delay_ms(1000);
    LED_1_Clear();
    delay_ms(1000);
   }
}
//////////////////////////////////////////////

void WriteComm(unsigned int i)
{
	 //CS0=0;
    // CS_X_Clear();
	 //RD0=1;
    DE_Clear();

 	 //DBH=i>>8;
	 //DBL=i;

    //--R--//
     //1
     if(i>>1 == 1)
     {
       DR3_Set();
     }
     else
     {
       DR3_Clear();
     }
     //2
     if(i>>2 == 1)
     {
       DR4_Set();
     }
     else
     {
       DR4_Clear();
     }
     //3
     if(i>>3 == 1)
     {
       DR5_Set();
     }
     else
     {
       DR5_Clear();
     }
     //4
     if(i>>4 == 1)
     {
       DR6_Set();
     }
     else
     {
       DR6_Clear();
     }
     //5
     if(i>>5 == 1)
     {
       DR7_Set();
     }
     else
     {
       DR7_Clear();
     }

     //---G---//---------------------------
     if(i>>6 == 1)
     {
       DG2_Set();
     }
     else
     {
       DG2_Clear();
     }

     if(i>>7 == 1)
     {
       DG3_Set();
     }
     else
     {
       DG3_Clear();
     }

     if(i>>8 == 1)
     {
       DG4_Set();
     }
     else
     {
       DG4_Clear();
     }

     if(i>>9 == 1)
     {
       DG5_Set();
     }
     else
     {
       DG5_Clear();
     }

     if(i>>10 == 1)
     {
       DG6_Set();
     }
     else
     {
       DG6_Clear();
     }

     if(i>>11 == 1)
     {
       DG7_Set();
     }
     else
     {
       DG7_Clear();
     }

     //--B--//-------------------------------------
     if(i>>12 == 1)
     {
       DB3_Set();
     }
     else
     {
       DB3_Clear();
     }

     if(i>>13 == 1)
     {
       DB4_Set();
     }
     else
     {
       DB4_Clear();
     }

     if(i>>14 == 1)
     {
       DB5_Set();
     }
     else
     {
       DB5_Clear();
     }

     if(i>>15 == 1)
     {
       DB6_Set();
     }
     else
     {
       DB6_Clear();
     }

     if(i>>16 == 1)
     {
       DB7_Set();
     }
     else
     {
       DB7_Clear();
     }

	 D_SCK_Clear();//WR0=0;
     delay_us(1);
	 D_SCK_Set();//WR0=1;
     delay_us(1);

	 //CS0=1
    // CS_X_Set();
}

void WriteData(unsigned int i)
{
	 //CS0=0;
    //CS_X_Clear();
	 //RD0=1;
	 DE_Set();

	 //DBH=i>>8;
	 //DBL=i;

//     PORTGbits.RG0 = i>>1;
//     PORTGbits.RG1 = i>>2;
//     PORTFbits.RF1 = i>>3;
//     PORTFbits.RF0 = i>>4;
//     PORTDbits.RD12 = i>>5;
//     PORTDbits.RD2 = i>>6;
//     PORTDbits.RD3 = i>>7;
//     PORTKbits.RK3 = i>>8;
//     PORTKbits.RK4 = i>>9;
//     PORTKbits.RK5 = i>>10;
//     PORTKbits.RK6 = i>>11;
//     PORTKbits.RK7 = i>>12;
//     PORTJbits.RJ3 = i>>13;
//     PORTHbits.RH15 = i>>14;
//     PORTDbits.RD13 = i>>15;
//     PORTKbits.RK0 = i>>16;

     //--R--//
     //1
     if(i>>1 == 1)
     {
       DR3_Set();
     }
     else
     {
       DR3_Clear();
     }
     //2
     if(i>>2 == 1)
     {
       DR4_Set();
     }
     else
     {
       DR4_Clear();
     }
     //3
     if(i>>3 == 1)
     {
       DR5_Set();
     }
     else
     {
       DR5_Clear();
     }
     //4
     if(i>>4 == 1)
     {
       DR6_Set();
     }
     else
     {
       DR6_Clear();
     }
     //5
     if(i>>5 == 1)
     {
       DR7_Set();
     }
     else
     {
       DR7_Clear();
     }

     //---G---//---------------------------
     if(i>>6 == 1)
     {
       DG2_Set();
     }
     else
     {
       DG2_Clear();
     }

     if(i>>7 == 1)
     {
       DG3_Set();
     }
     else
     {
       DG3_Clear();
     }

     if(i>>8 == 1)
     {
       DG4_Set();
     }
     else
     {
       DG4_Clear();
     }

     if(i>>9 == 1)
     {
       DG5_Set();
     }
     else
     {
       DG5_Clear();
     }

     if(i>>10 == 1)
     {
       DG6_Set();
     }
     else
     {
       DG6_Clear();
     }

     if(i>>11 == 1)
     {
       DG7_Set();
     }
     else
     {
       DG7_Clear();
     }

     //--B--//-------------------------------------
     if(i>>12 == 1)
     {
       DB3_Set();
     }
     else
     {
       DB3_Clear();
     }

     if(i>>13 == 1)
     {
       DB4_Set();
     }
     else
     {
       DB4_Clear();
     }

     if(i>>14 == 1)
     {
       DB5_Set();
     }
     else
     {
       DB5_Clear();
     }

     if(i>>15 == 1)
     {
       DB6_Set();
     }
     else
     {
       DB6_Clear();
     }

     if(i>>16 == 1)
     {
       DB7_Set();
     }
     else
     {
       DB7_Clear();
     }  

	 D_SCK_Clear();//WR0=0;
     delay_us(1);
	 D_SCK_Set();//WR0=1;
     delay_us(1);

     //CS0=1;
     //CS_X_Set();
}

void BlockWrite(unsigned int Xstart,unsigned int Xend,unsigned int Ystart,unsigned int Yend)
{
	//SSD1963
//	Ystart=Ystart+4;
//	Yend=Yend+4;

	WriteComm(0x2a);
	WriteData(Xstart>>8);
	WriteData(Xstart&0xff);
	WriteData(Xend>>8);
	WriteData(Xend&0xff);

	WriteComm(0x2b);
	WriteData(Ystart>>8);
	WriteData(Ystart&0xff);
	WriteData(Yend>>8);
	WriteData(Yend&0xff);

	WriteComm(0x2c);
}

void DispColor(unsigned int color)
{
    unsigned int i,j;

	BlockWrite(0,COL-1,0,ROW-1);

	//CS0=0;
    //CS_X_Clear();
	//RD0=1;
	//RS=1;
    DE_Set();

//	DBH=color>>8;
//	DBL=color;

    //--R--//
     //1
     if(color>>1 == 1)
     {
       DR3_Set();
     }
     else
     {
       DR3_Clear();
     }
     //2
     if(color>>2 == 1)
     {
       DR4_Set();
     }
     else
     {
       DR4_Clear();
     }
     //3
     if(color>>3 == 1)
     {
       DR5_Set();
     }
     else
     {
       DR5_Clear();
     }
     //4
     if(color>>4 == 1)
     {
       DR6_Set();
     }
     else
     {
       DR6_Clear();
     }
     //5
     if(color>>5 == 1)
     {
       DR7_Set();
     }
     else
     {
       DR7_Clear();
     }

     //---G---//---------------------------
     if(color>>6 == 1)
     {
       DG2_Set();
     }
     else
     {
       DG2_Clear();
     }

     if(color>>7 == 1)
     {
       DG3_Set();
     }
     else
     {
       DG3_Clear();
     }

     if(color>>8 == 1)
     {
       DG4_Set();
     }
     else
     {
       DG4_Clear();
     }

     if(color>>9 == 1)
     {
       DG5_Set();
     }
     else
     {
       DG5_Clear();
     }

     if(color>>10 == 1)
     {
       DG6_Set();
     }
     else
     {
       DG6_Clear();
     }

     if(color>>11 == 1)
     {
       DG7_Set();
     }
     else
     {
       DG7_Clear();
     }

     //--B--//-------------------------------------
     if(color>>12 == 1)
     {
       DB3_Set();
     }
     else
     {
       DB3_Clear();
     }

     if(color>>13 == 1)
     {
       DB4_Set();
     }
     else
     {
       DB4_Clear();
     }

     if(color>>14 == 1)
     {
       DB5_Set();
     }
     else
     {
       DB5_Clear();
     }

     if(color>>15 == 1)
     {
       DB6_Set();
     }
     else
     {
       DB6_Clear();
     }

     if(color>>16 == 1)
     {
       DB7_Set();
     }
     else
     {
       DB7_Clear();
     }

	for(i=0;i<ROW;i++)
	{
		for(j=0;j<COL;j++)
		{
            D_SCK_Clear();//WR0=0;
            delay_us(1);
            D_SCK_Set();//WR0=1;
            delay_us(1);
		}
	}
	//CS0=1;
    //CS_X_Set();
}

void WriteOneDot(unsigned int color)
{
	//CS0=0;
	//RD0=1;
	//RS=1;
    DE_Set();

	//DBH=color>>8;
	//DBL=color;

    //--R--//
     //1
     if(color>>1 == 1)
     {
       DR3_Set();
     }
     else
     {
       DR3_Clear();
     }
     //2
     if(color>>2 == 1)
     {
       DR4_Set();
     }
     else
     {
       DR4_Clear();
     }
     //3
     if(color>>3 == 1)
     {
       DR5_Set();
     }
     else
     {
       DR5_Clear();
     }
     //4
     if(color>>4 == 1)
     {
       DR6_Set();
     }
     else
     {
       DR6_Clear();
     }
     //5
     if(color>>5 == 1)
     {
       DR7_Set();
     }
     else
     {
       DR7_Clear();
     }

     //---G---//---------------------------
     if(color>>6 == 1)
     {
       DG2_Set();
     }
     else
     {
       DG2_Clear();
     }

     if(color>>7 == 1)
     {
       DG3_Set();
     }
     else
     {
       DG3_Clear();
     }

     if(color>>8 == 1)
     {
       DG4_Set();
     }
     else
     {
       DG4_Clear();
     }

     if(color>>9 == 1)
     {
       DG5_Set();
     }
     else
     {
       DG5_Clear();
     }

     if(color>>10 == 1)
     {
       DG6_Set();
     }
     else
     {
       DG6_Clear();
     }

     if(color>>11 == 1)
     {
       DG7_Set();
     }
     else
     {
       DG7_Clear();
     }

     //--B--//-------------------------------------
     if(color>>12 == 1)
     {
       DB3_Set();
     }
     else
     {
       DB3_Clear();
     }

     if(color>>13 == 1)
     {
       DB4_Set();
     }
     else
     {
       DB4_Clear();
     }

     if(color>>14 == 1)
     {
       DB5_Set();
     }
     else
     {
       DB5_Clear();
     }

     if(color>>15 == 1)
     {
       DB6_Set();
     }
     else
     {
       DB6_Clear();
     }

     if(color>>16 == 1)
     {
       DB7_Set();
     }
     else
     {
       DB7_Clear();
     }

	//WR0=0;
	//WR0=1;
    D_SCK_Clear();//WR0=0;
    delay_us(1);
    D_SCK_Set();//WR0=1;
    delay_us(1);

	//CS0=1;
}

void PutPixel(unsigned int x,unsigned int y,unsigned int color)
{
	#if 0
	BlockWrite(x,x+1,y,y+1);

	//CS0=0;
	//RD0=1;
	RS=1;

	DBH=color>>8;
	DBL=color;  

	WR0=0;
	WR0=1; 

	WR0=0;
	WR0=1; 

	WR0=0;
	WR0=1; 

	WR0=0;
	WR0=1; 

	//CS0=1;
	#endif

	#if 1
	unsigned char i;

 	for (i=0;i<3;i++)
 	{
       BlockWrite(x,COL-1,y+i,ROW-1);
	   WriteOneDot(color);
	   WriteOneDot(color);
    } 

	#endif
}

void DrawLine(unsigned int Xstart,unsigned int Xend,unsigned int Ystart,unsigned int Yend,unsigned int color)
{
	unsigned int i,j;

	BlockWrite(Xstart,Xend,Ystart,Yend);

	for(i=Ystart;i<Yend+1;i++)
	{
		for(j=Xstart;j<Xend+1;j++)
		{
			WriteOneDot(color);
		}
	}
}

void DrawGird(unsigned int color)
{
	unsigned int i;

	for(i=15;i<ROW-1;i=i+16)
	{
		DrawLine(0,COL-1,i,i,color);

	}

	for(i=15;i<COL-1;i=i+16)
	{
		DrawLine(i,i,0,ROW-1,color);
	}

}

// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all modules */
    SYS_Initialize ( NULL );
    //SPI1_Initialize();
    D_LED_Set();  

    LCD_Init();
    //DispColor(RED);
    //DrawLine(0,50,2,40,BLUE);
    led_blinky();

//    DE_Set();
//    delay_us(2);
//
//    DR7_Set();
//    DR6_Set();
//    DR5_Set();
//    DR4_Set();
//    DR3_Set();

   // DispColor(0x2410);
    //SYS_Tasks( );

//    VS_Clear();
//    delay_us(2);
//    //VS_Set();
//    //delay_us(2);
//
//    HS_Clear();
//    delay_us(2);
//    //HS_Set();
//    //delay_us(2);
//
//    for(int p=0;p<100;p++)
//    {
//        D_SCK_Clear();
//        delay_us(1);
//        D_SCK_Set();
//        delay_us(1);
//    }

//    while ( true )
//    {
//    /* Maintain state machines of all polled MPLAB Harmony modules. */
//        SYS_Tasks( );
//        DispColor(RED);
//
//    }

    /* Execution should not come here during normal operation */

    //return ( EXIT_FAILURE );
}

/*******************************************************************************
 End of File
*/

Please help me to run this display.

 

Best Regards

 

Rajbir 

Attachment(s): 

Last Edited: Thu. Nov 11, 2021 - 12:08 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should ask at the Microchip forum not here.

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly