/*-------------北京青云創新科技發展有限公司-------------*/ /*電話:010-62168698/99 ,010-62168668/69 */ /*傳真:010-62118966*/ /*------------------CopyRight 1999-2010-----------------*/ #include #include #include #define uint unsigned int #define uchar unsigned char #define D_PORT P0 sbit CS =P2^0; sbit SID =P2^1; sbit SCLK =P2^2; #define LCD_BUS P0 uchar code hztab[16*64]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x88,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xA8,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x98,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x88,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x8C,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x04,0xE4,0x75,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x94,0x55,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x0F,0x7C,0x72,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x07,0x30,0x01,0xFE,0x00,0x00,0x00,0x00, 0x02,0xFC,0x00,0x02,0x00,0x00,0x00,0x00,0x02,0x10,0x01,0xFE,0x00,0x00,0x00,0x00, 0x0D,0x50,0x00,0x02,0x00,0x00,0x00,0x00,0x01,0x10,0x01,0xFE,0x00,0x00,0x00,0x00, 0x05,0x50,0x00,0x02,0x00,0x00,0x00,0x00,0x01,0x10,0x01,0xFE,0x00,0x00,0x00,0x00, 0x02,0xFC,0x00,0x02,0x00,0x00,0x00,0x00,0x07,0x38,0x01,0xFE,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x02,0x3B,0x80,0x00,0x00,0x00,0x00,0x01,0xFE,0x00,0x00,0x00,0x00, 0x00,0x00,0x12,0x02,0x2A,0x80,0x00,0x00,0x00,0x00,0x01,0xFE,0x00,0x00,0x00,0x00, 0x00,0x00,0x35,0x02,0x11,0x00,0x00,0x00,0x00,0x00,0x01,0xFE,0x00,0x00,0x00,0x00, 0x04,0x80,0x55,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00, 0x02,0x80,0x35,0x02,0x3B,0x80,0x00,0x00,0x00,0x00,0x01,0xFE,0x00,0x00,0x00,0x00, 0x02,0x80,0x12,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFE,0x00,0x62,0x00,0x00, 0x03,0x80,0x00,0x02,0x00,0x00,0x06,0x60,0x00,0x00,0x01,0xFE,0x00,0x26,0x00,0x00, 0x0C,0x80,0x00,0x02,0x00,0x00,0x02,0x20,0x03,0xF8,0x01,0xFE,0x00,0x2A,0x00,0x00, 0x03,0x80,0x00,0x02,0x00,0x00,0x02,0x20,0x03,0xF8,0x01,0xFE,0x00,0x26,0x00,0x00, 0x02,0x80,0x00,0x02,0x00,0x00,0x02,0x20,0x03,0xF8,0x01,0xFE,0x00,0x72,0x00,0x00, 0x02,0x80,0x00,0x02,0x00,0x00,0x07,0x70,0x03,0xF8,0x01,0xFE,0x00,0x00,0x00,0x00, 0x00,0x78,0x72,0x02,0x00,0x00,0x00,0x00,0x03,0xF8,0x01,0xFE,0x00,0x00,0x00,0x00, 0x00,0x04,0x55,0x02,0x1F,0xC0,0x00,0x00,0x03,0xF8,0x01,0xFE,0x00,0x00,0x00,0x00, 0x00,0x00,0x25,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00, 0x00,0x00,0x45,0x02,0x1F,0xC0,0x00,0x00,0x03,0xF8,0x01,0xFE,0x00,0x00,0x00,0x00, 0x00,0x00,0x72,0x02,0x1F,0xC0,0x00,0x00,0x03,0xF8,0x01,0xFE,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x02,0x1F,0xC0,0x00,0x00,0x03,0xF8,0x01,0xFE,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x02,0x1F,0xC0,0x00,0x00,0x03,0xF8,0x01,0xFE,0x00,0x7F,0x00,0x00, 0x00,0x00,0x00,0x02,0x1F,0xC0,0x0F,0xF0,0x03,0xF8,0x01,0xFE,0x00,0x7F,0x00,0x00, 0x00,0x00,0x00,0x02,0x1F,0xC0,0x0F,0xF0,0x03,0xF8,0x01,0xFE,0x00,0x7F,0x00,0x00, 0x00,0x00,0x00,0x02,0x1F,0xC0,0x0F,0xF0,0x03,0xF8,0x01,0xFE,0x00,0x7F,0x00,0x00, 0x00,0x00,0x00,0x02,0x1F,0xC0,0x0F,0xF0,0x03,0xF8,0x01,0xFE,0x00,0x7F,0x00,0x00, 0x00,0x00,0x02,0x02,0x1F,0xC0,0x0F,0xF0,0x03,0xF8,0x01,0xFE,0x00,0x7F,0x00,0x00, 0x00,0x00,0x05,0x02,0x1F,0xC1,0x0F,0xF0,0x43,0xF8,0x21,0xFE,0x08,0x7F,0x04,0x00, 0x00,0x00,0x05,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00, 0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x81,0x50,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x82,0x50,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x82,0x88,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x87,0x06,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x8A,0xF8,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x82,0x48,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x82,0x48,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x82,0x90,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x03,0x10,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; /*void ddram_clear() { /*set basic instruction;*/ /*write_comm(0x30,0); /*clear ddram=20h*/ /* write_comm(0x1,0); /*set AC=0, D=1 C=1 //write_comm(0x26,0); //write_comm(0x30,0); }*/ void write_comm(bdata char cmd_dat) { unsigned int i,j,k; CS=1;SID=1; for(i=0;i<5;i++) { CLK=0;CLK=1; } CLK=0;SID=0;CLK=1; CLK=0;CLK=1; CLK=0;CLK=1; CLK=0;SID=cmd_dat^7;CLK=1; CLK=0;SID=cmd_dat^6;CLK=1; CLK=0;SID=cmd_dat^5;CLK=1; CLK=0;SID=cmd_dat^4;CLK=1; CLK=0;SID=0;CLK=1; CLK=0;CLK=1; CLK=0;CLK=1; CLK=0;CLK=1; CLK=0;SID=cmd_dat^3;CLK=1; CLK=0;SID=cmd_dat^2;CLK=1; CLK=0;SID=cmd_dat^1;CLK=1; CLK=0;SID=cmd_dat^0;CLK=1; CLK=0;SID=0;CLK=1; CLK=0;CLK=1; CLK=0;CLK=1; CLK=0;CLK=1; CLK=0;CS=0; delay() } void write_dat(bdata char dat_dat) { unsigned int i,j,k; CS=1;SID=1; for(i=0;i<5;i++) { CLK=0;CLK=1; } CLK=0;SID=0;CLK=1; CLK=0;SID=1;CLK=1; CLK=0;SID=0;CLK=1; CLK=0;SID=dat_dat^7;CLK=1; CLK=0;SID=dat_dat^6;CLK=1; CLK=0;SID=dat_dat^5;CLK=1; CLK=0;SID=dat_dat^4;CLK=1; CLK=0;SID=0;CLK=1; CLK=0;CLK=1; CLK=0;CLK=1; CLK=0;CLK=1; CLK=0;SID=dat_dat^3;CLK=1; CLK=0;SID=dat_dat^2;CLK=1; CLK=0;SID=dat_dat^1;CLK=1; CLK=0;SID=dat_dat^0;CLK=1; CLK=0;SID=0;CLK=1; CLK=0;CLK=1; CLK=0;CLK=1; CLK=0;CLK=1; CLK=0;CS=0; delay() } void delay() { unsigned int i,j,k; for(i=0;i<100;i++) //for(j=0;j<100;j++) for(k=0;k<100;k++); } void main() { unsigned int i,j,k; delay(); delay(); delay(); write_comm(0x30); delay(); write_comm(0x30); delay(); write_comm(0x30); delay(); write_comm(0x30); delay(); write_comm(0x0c); delay(); write_comm(0x06); delay(); write_comm(0x01); write_comm(0x92); write_dat(0xc7); write_dat(0xe0); write_dat(0xD4); write_dat(0xC6); write_dat(0xB4); write_dat(0xB4); write_dat(0xD0); write_dat(0xC2); delay(); delay(); delay(); write_comm(0x92); write_dat(0xb0); write_dat(0xa0); write_dat(0xb0); write_dat(0xa0); write_dat(0xb0); write_dat(0xa0); write_dat(0xb0); write_dat(0xa0); write_comm(0x36); k=0; for(j=0;j<32;j++) { write_comm(0x80+j); write_comm(0x80); for(i=0;i<16;i++) { write_dat(hztab[k]); k++; } } for(j=0;j<32;j++) { write_comm(0x80+j); write_comm(0x88); for(i=0;i<16;i++) { write_dat(hztab[k]); k++; } } while(1); }