//------------------------------------------------- // Shenzhen TOPWAY Technology Co.,Ltd. // LCD Module: LMT035-NHN // System: W78E516D(12MHz, 6T) // Display Size: 320(RGB)x240 // Driver/Controller: S1D13L01 // Interface: I/O 80mode // Version: V2, add TFT initialization // Date: 2015-09-22 // by Bill.Chen // note: PLL mode 10M CLKI 66M MCLK 6.6M PCLK //------------------------------------------------- #include #include #include #include #define uchar unsigned char // 8bit, 0 ~ 255 #define uint unsigned int // 16bit, 0 ~ 65,535 #define ulong unsigned long // 32bit, 0 ~ 4,294,967,295 //----------------------------------- // define I/O //----------------------------------- #define LCDBUS P1 sbit _CS = P3^1; sbit _RST = P3^2; sbit A0 = P3^0; sbit _RD = P3^4; sbit _WR = P3^5; sbit BL_ADJ = P3^6; // //----------------------------------- // define 16bit colors //----------------------------------- #define RED 0xf800 #define GREEN 0x07e0 #define BLUE 0x001f #define YELLOW 0xffe0 #define CYAN 0x07ff #define MAGENTA 0xf81f #define BLACK 0x0000 #define WHITE 0xffff // #define mid_re 0x8000 #define mid_or 0x8200 #define mid_ye 0x8400 #define mid_yg 0x4400 #define mid_gr 0x0400 #define mid_gc 0x0408 #define mid_cy 0x0410 #define mid_cb 0x0210 #define mid_bl 0x0010 #define mid_bm 0x4010 #define mid_ma 0x8010 #define mid_mr 0x8008 // #define GRAY00 0x0000 #define GRAY01 0x1082 #define GRAY02 0x2104 #define GRAY03 0x3186 #define GRAY04 0x4208 #define GRAY05 0x528a #define GRAY06 0x630c #define GRAY07 0x738e #define GRAY08 0x8410 #define GRAY09 0x9492 #define GRAY10 0xa514 #define GRAY11 0xb596 #define GRAY12 0xc618 #define GRAY13 0xd69a #define GRAY14 0xe71c #define GRAY15 0xffff // //----------------------------------------------------------------------------- // 160W*53H*16bit_TOPWAY(mono).bmp code //----------------------------------------------------------------------------- uchar code TOPWAY[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0x00,0x3F,0xE0,0x07,0xFF, 0xF8,0x0F,0xC7,0xF3,0xF8,0x03,0xF8,0x03,0xF8,0x00,0xFE,0x00,0x1F,0xFF,0xFF,0x00, 0xFF,0xF8,0x07,0xFF,0xFE,0x0F,0xC7,0xF3,0xF8,0x03,0xF8,0x01,0xFC,0x01,0xFC,0x00, 0x1F,0xFF,0xFF,0x01,0xFF,0xFC,0x07,0xFF,0xFF,0x0F,0xE7,0xF3,0xF8,0x03,0xF8,0x01, 0xFC,0x01,0xF8,0x00,0x00,0x3F,0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0x07,0xF0,0x01,0xFC,0x00,0x00,0x00,0x3F,0x80,0x0F, 0xE0,0x3F,0x87,0xF0,0x00,0x01,0xFE,0x3F,0xC1,0xFC,0x07,0xF0,0x01,0xFC,0x00,0x00, 0x00,0x3F,0x80,0x0F,0xE0,0x3F,0x87,0xF0,0x00,0x01,0xFE,0x3F,0xC1,0xF8,0x03,0xF0, 0x01,0xFC,0x00,0x00,0x00,0x3F,0x80,0x07,0xF0,0x7F,0x07,0xF0,0x00,0x01,0xFE,0x3F, 0x83,0xF8,0x03,0xF8,0x01,0xFC,0x00,0x00,0x00,0x3F,0x80,0x07,0xF0,0x7F,0x07,0xF0, 0x00,0x01,0xFE,0x3F,0x83,0xF8,0x03,0xF8,0x01,0xFC,0x00,0x00,0x00,0x3F,0x80,0x03, 0xFD,0xFE,0x07,0xF0,0x00,0x01,0xFC,0x3F,0x83,0xF8,0x03,0xF8,0x01,0xFC,0x00,0x00, 0x00,0x3F,0x80,0x01,0xFF,0xFC,0x07,0xF0,0x00,0x00,0xFC,0x3F,0x87,0xF0,0x01,0xFC, 0x01,0xFC,0x00,0x00,0x00,0x3F,0x80,0x00,0xFF,0xF8,0x07,0xF0,0x00,0x00,0xFC,0x1F, 0x87,0xF0,0x01,0xFC,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xE0,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00 }; // //----------------------------------------------------------------------------- // 160W*53H*16bit_LMT035KDH03-NHN_320x240pixel(mono).bmp code //----------------------------------------------------------------------------- uchar code Module[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x0C,0x19,0xFE, 0x1F,0x07,0x87,0xF9,0x87,0x7C,0x18,0x61,0xF0,0x78,0x00,0x18,0x66,0x19,0x86,0x00, 0x18,0x0C,0x18,0x30,0x31,0x8C,0xC6,0x01,0x8E,0x67,0x18,0x63,0x18,0xCC,0x00,0x1C, 0x66,0x19,0xC6,0x00,0x18,0x0E,0x38,0x30,0x31,0x98,0x66,0x01,0x9C,0x63,0x18,0x63, 0x19,0x86,0x00,0x1C,0x66,0x19,0xC6,0x00,0x18,0x0E,0x38,0x30,0x60,0xD8,0x66,0x01, 0xB8,0x61,0x98,0x66,0x0D,0x86,0x00,0x1E,0x66,0x19,0xE6,0x00,0x18,0x0E,0x38,0x30, 0x60,0xC0,0x66,0xE1,0xB0,0x61,0x98,0x66,0x0C,0x06,0x00,0x1E,0x66,0x19,0xE6,0x00, 0x18,0x0E,0x38,0x30,0x60,0xC0,0xC7,0x31,0xF0,0x61,0x9F,0xE6,0x0C,0x0C,0xFF,0x9B, 0x67,0xF9,0xB6,0x00,0x18,0x0D,0x58,0x30,0x60,0xC3,0x86,0x19,0xF0,0x61,0x98,0x66, 0x0C,0x38,0x00,0x1B,0x66,0x19,0xB6,0x00,0x18,0x0D,0x58,0x30,0x60,0xC0,0xC0,0x19, 0xD8,0x61,0x98,0x66,0x0C,0x0C,0x00,0x1B,0xE6,0x19,0xBE,0x00,0x18,0x0D,0x58,0x30, 0x60,0xC0,0x60,0x19,0x98,0x61,0x98,0x66,0x0C,0x06,0x00,0x19,0xE6,0x19,0x9E,0x00, 0x18,0x0D,0x58,0x30,0x60,0xD8,0x66,0x19,0x8C,0x61,0x98,0x66,0x0D,0x86,0x00,0x19, 0xE6,0x19,0x9E,0x00,0x18,0x0D,0xD8,0x30,0x31,0x98,0x66,0x19,0x8E,0x63,0x18,0x63, 0x19,0x86,0x00,0x18,0xE6,0x19,0x8E,0x00,0x18,0x0C,0x98,0x30,0x31,0x8C,0xC3,0x31, 0x86,0x63,0x18,0x63,0x18,0xCC,0x00,0x18,0xE6,0x19,0x8E,0x00,0x1F,0xEC,0x98,0x30, 0x1F,0x07,0x81,0xE1,0x87,0x7C,0x18,0x61,0xF0,0x78,0x00,0x18,0x66,0x19,0x86,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x81,0xE0,0x7C, 0x00,0x00,0x00,0x00,0x78,0x03,0x07,0xC0,0x01,0xF8,0x0C,0x00,0x00,0x00,0x30,0x00, 0x0C,0xC3,0x30,0xC6,0x00,0x03,0x00,0x00,0xCC,0x07,0x0C,0x60,0x01,0x8C,0x0C,0x00, 0x00,0x00,0x30,0x00,0x18,0x66,0x18,0xC6,0x00,0x03,0x00,0x01,0x86,0x07,0x0C,0x60, 0x01,0x86,0x00,0x00,0x00,0x00,0x30,0x00,0x18,0x66,0x19,0x83,0x00,0x33,0x30,0x01, 0x86,0x0B,0x18,0x30,0x01,0x86,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x66,0x19,0x83, 0x00,0x1F,0xE0,0x01,0x86,0x13,0x18,0x30,0x01,0x86,0x0C,0x1C,0xE1,0xE0,0x30,0x00, 0x00,0xC0,0x39,0x83,0x00,0x07,0x80,0x00,0x0E,0x13,0x18,0x30,0x01,0x86,0x0C,0x0C, 0xC3,0x30,0x30,0x00,0x03,0x80,0x31,0x83,0x00,0x0F,0xC0,0x00,0x0C,0x23,0x18,0x30, 0x01,0x8C,0x0C,0x07,0x86,0x18,0x30,0x00,0x00,0xC0,0x61,0x83,0x00,0x3B,0x70,0x00, 0x18,0x63,0x18,0x30,0x01,0xF8,0x0C,0x07,0x87,0xF8,0x30,0x00,0x00,0x60,0xC1,0x83, 0x00,0x13,0x20,0x00,0x30,0x7F,0xD8,0x30,0x01,0x80,0x0C,0x03,0x06,0x00,0x30,0x00, 0x18,0x61,0x81,0x83,0x00,0x03,0x00,0x00,0x60,0x03,0x18,0x30,0x01,0x80,0x0C,0x07, 0x86,0x00,0x30,0x00,0x18,0x63,0x00,0xC6,0x00,0x03,0x00,0x00,0xC0,0x03,0x0C,0x60, 0x01,0x80,0x0C,0x07,0x86,0x18,0x30,0x00,0x0C,0xC6,0x00,0xC6,0x00,0x00,0x00,0x01, 0x80,0x03,0x0C,0x60,0x01,0x80,0x0C,0x0C,0xC3,0x30,0x30,0x00,0x07,0x87,0xF8,0x7C, 0x00,0x00,0x00,0x01,0xFE,0x03,0x07,0xC0,0x01,0x80,0x0C,0x1C,0xE1,0xE0,0x30,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00 }; // //----------------------------------------------------------------------------- // delayms routine // Parameter:m = time in ms //----------------------------------------------------------------------------- void delayms(uint m) // 12MHz Crystal, close to ms value { uint j; uint i; for(i=0; i>8; Ddata18=Command>>16; A0 = 0; _CS = 0; LCDBUS = Command; // Write the 1st lower 8bit(A7-0) _WR = 0; _WR = 1; LCDBUS = Ddata15; // Write the 2nd lower 8bit(A15-8) _WR = 0; _WR = 1; LCDBUS = Ddata18; // Write the highest 3bit(A18-16) _WR = 0; _WR = 1; _CS=1; } // //----------------------------------------------------------------------------- // Write 16bit Data Command routine // Parameter:Write Data // 1. Write the low 8bit // 2. Write the high 8bit //----------------------------------------------------------------------------- void SdData(uint DData) { A0 = 1; _CS = 0; LCDBUS = DData; // Write the low 8bit(D7-0) _WR = 0; _WR = 1; LCDBUS = DData>>8; // Write the high 8bit(D15-8) _WR = 0; _WR = 1; _CS=1; } // //----------------------------------- // TFT driver Reg setting //----------------------------------- void SPI_Write8(uchar RegAdd, uchar RegDat) // T8000 and TFT SPI connection // GPIO0=_SENA, GPIO1=SCLK, GPIO2=SDIN // using S1D13L01 GPIO to sent command into TFT SPI port { uchar i; SdCmd(0x608D0); SdData(0x0007); // GPIO3 is input, GPIO[2:0] are output SdCmd(0x608D2); SdData(0x0007); //SENA=1; SCLK=1;SDIN=1; for(i=0; i<8; i++) // write the address { if(RegAdd&0x80) { SdCmd(0x608D2);SdData(0x0004); //SENA=0; SCLK=0;SDIN=1; SdCmd(0x608D2);SdData(0x0006); //SENA=0; SCLK=1;SDIN=1; SdCmd(0x608D2);SdData(0x0004); //SENA=0; SCLK=0;SDIN=1; } else { SdCmd(0x608D2);SdData(0x0000); //SENA=0; SCLK=0;SDIN=0; SdCmd(0x608D2);SdData(0x0002); //SENA=0; SCLK=1;SDIN=0; SdCmd(0x608D2);SdData(0x0000); //SENA=0; SCLK=0;SDIN=0; } RegAdd=RegAdd<<1; } for(i=0; i<8; i++) // write the data { if(RegDat&0x80) { SdCmd(0x608D2);SdData(0x0004); //SENA=0; SCLK=0;SDIN=1; SdCmd(0x608D2);SdData(0x0006); //SENA=0; SCLK=1;SDIN=1; SdCmd(0x608D2);SdData(0x0004); //SENA=0; SCLK=0;SDIN=1; } else { SdCmd(0x608D2);SdData(0x0000); //SENA=0; SCLK=0;SDIN=0; SdCmd(0x608D2);SdData(0x0002); //SENA=0; SCLK=1;SDIN=0; SdCmd(0x608D2);SdData(0x0000); //SENA=0; SCLK=0;SDIN=0; } RegDat=RegDat<<1; } SdCmd(0x608D2);SdData(0x0007); //SENA=1; SCLK=1;SDIN=1; } // //----------------------------------- // TFT driver Reg setting //----------------------------------- void TFT_Init(void) { SPI_Write8(0x02,0x07);//R00 SPI_Write8(0x06,0x00);//R01 SPI_Write8(0x0A,0x03);//R02 SPI_Write8(0x0E,0xCC);//R03 SPI_Write8(0x12,0x46);//R04 SPI_Write8(0x16,0x0D);//R05 SPI_Write8(0x1A,0x00);//R06 SPI_Write8(0x1E,0x00);//R07 SPI_Write8(0x22,0x08);//R08 SPI_Write8(0x26,0x40);//R09 SPI_Write8(0x2A,0x88);//R0A SPI_Write8(0x2E,0x88);//R0B SPI_Write8(0x32,0x20);//R0C SPI_Write8(0x36,0x20);//R0D SPI_Write8(0x3A,0x68);//R0E SPI_Write8(0x3E,0xA5);//R0F SPI_Write8(0x42,0x04);//R10 SPI_Write8(0x46,0x24);//R11 SPI_Write8(0x4A,0x24);//R12 SPI_Write8(0x7A,0x05);//R1E SPI_Write8(0x82,0x00);//R20 } // //----------------------------------------------------------------------------- // Fill full screen routine // Parameter:fill color // 1. Write the start Address // 2. Write the Horizontal Data // 3. Change the next Horizontal Address // 4. Write next Horizontal Data //----------------------------------------------------------------------------- void FillFullScn(uint color) { ulong addr; uint i,j; addr=0; for(i=0;i<240;i++) { SdCmd(addr); // Write the start Address for(j=0;j<320;j++) { SdData(color); // Write the Horizontal Data } addr=addr+640; // Next Horizontal Address } } // //----------------------------------------------------------------------------- // Fill Box routine // Parameter:fill color,start position of X,start position of Y, width of Box, High of Box // 1. Write the start Address // 2. Write the Horizontal Data // 3. Change the next Horizontal Address // 4. Write next Horizontal Data //----------------------------------------------------------------------------- void FillBox(uint color,x,y,w,h) { ulong addr; uint i,j; addr=640; addr=addr*y; addr=addr+x*2; for(i=0;i CLKI = 10 MHz / 5 => 2MHz SdCmd(0x60814); SdData(0x0020); // L = 0x20 => POCLK = 2MHz * 33 = 66 MHz SdCmd(0x60810); SdData(0x0001); // Dont Enable PLL, Bypass delayms(100); SdCmd(0x60816); SdData(0x0008); // With PLL: PCLK := 66MHz / 10 = 6.6MHz SdCmd(0x60804); SdData(0x0001); // Enable Memory Power / Clock delayms(100); // Panel setting SdCmd(0x60820); SdData(0x008f); // DE is low, Data ready on PCLK rising edge, 24Bit enabled SdCmd(0x60822); SdData(0x0001); // TE is off, Inverted Data SdCmd(0x60824); SdData(0x0028); // The display period of HS = 320/8 = 40 SdCmd(0x60826); SdData(0x0058); // The empty period of HS = 88 SdCmd(0x6082c); SdData(0x0002); // HS Polarity = 0, Pulse width = 2 SdCmd(0x6082e); SdData(0x0012); // The start position of HS = 18 SdCmd(0x60828); SdData(0x00f0); // The display period of VS = 240 SdCmd(0x6082a); SdData(0x0015); // The empty period of VS = 22 SdCmd(0x60830); SdData(0x0001); // VS Polarity = 0, Pulse width = 1 SdCmd(0x60832); SdData(0x0008); // The start position of VS = 8 // Main Panel RAM setting SdCmd(0x60840); SdData(0x0001); // Main Panel&PIP enable, and Main Panel display data is RGB=565 SdCmd(0x60842); SdData(0x0000); // The start Address of Main Panel = 00000h SdCmd(0x60844); SdData(0x0000); // // PIP RAM setting SdCmd(0x60850); SdData(0x0001); // PIP display data is RGB=565 SdCmd(0x60852); SdData(0x6000); // The start Address of Main Panel = 26000h SdCmd(0x60854); SdData(0x0002); // SdCmd(0x60856); SdData(0x0096); // Display width of PIP = 150 SdCmd(0x60858); SdData(0x0055); // Display width of PIP = 85 SdCmd(0x6085a); SdData(0x0000); // The start position of X of PIP = 0 SdCmd(0x6085c); SdData(0x0000); // The start position of Y of PIP = 0 SdCmd(0x60860); SdData(0x0000); // No PIP SdCmd(0x60862); SdData(0x0000); // SdCmd(0x60864); SdData(0x0000); // Transparency disable SdCmd(0x60866); SdData(0x0000); // Transparency Key Color setting SdCmd(0x60868); SdData(0x0000); // Transparency Key Color setting //GPIO setting SdCmd(0x608D0); SdData(0x0007); // GPIO3 is input, GPIO[2:0] are output SdCmd(0x608D2); SdData(0x0007); // GPIO[2:0] output high SdCmd(0x60804); SdData(0x0002); // PSM1 Mode, Enable Mem and Panel Clock delayms(100); } // //----------------------------------------------------------------------------- // Main program // 1. I/O initialization // 2. Reset MCU // 3. LCD initialization // 4. Fill Picture // 5. Loop forever //----------------------------------------------------------------------------- void main() { EA=0; // no interrupt _WR=1; _RD=1; _CS = 1; BL_ADJ=1; // Open the Backlight of TFT _RST=1; delayms(100); // wait for all power stable _RST=0; delayms(100); // reset pulse _RST=1; delayms(800); // wait till internal reset routine finish initLCM(); // LCD initialization TFT_Init(); // TFT initialization FillFullScn(BLACK); FillBox(mid_re, 0, 0,72,53); Checker30x30(RED, 22, 14); FillBox(mid_or, 83, 0,72,53); FillBox(mid_ye,165, 0,72,53); FillBox(mid_yg,247, 0,72,53); FillBox(mid_gr,247, 63,72,53); Checker30x30(GREEN,268, 75); FillBox(mid_gc,247,124,72,53); FillBox(mid_cy,247,186,72,53); FillBox(mid_cb,165,186,72,53); FillBox(mid_bl, 83,186,72,53); Checker30x30(BLUE,104,197); FillBox(mid_bm, 0,186,72,53); FillBox(mid_ma, 0,124,72,53); FillBox(mid_mr, 0, 63,72,53); monoFill160x53(83, 63, GRAY04, BLACK, TOPWAY ); monoFill160x53(83, 124, GRAY04, BLACK, Module ); while(1); } // //----------------------------------------------------------------------------- // End off //-----------------------------------------------------------------------------