//;****************************************************************************** //; FSA506 CONTROLLER for 8bit 5.7" // //;****************************************************************************** #include #include // define I/O functions #include // KEIL FUNCTION #define Data_BUS P1 //#define DELAYTime 0x028E sbit R_D =P3^4; //P3.0 sbit W_R =P3^7; sbit CS1 =P3^1; sbit RS =P3^0; //P3.4 sbit RST =P3^6; sbit SEL =P3^5; sbit UP =P2^2; sbit LR =P2^3; sbit STP =P2^0; sbit S_S =P2^1; unsigned char code pic[9600]; //;****************************************************************************** void STP_SC(void) { unsigned char x,y,z; z=P2; P2=z|| 0x03; if(S_S == 1) { do{ for(x=0;x<255;x++) { for(y=0;y<255;y++) {}} P2=z|| 0x03; }while(STP == 0); } } //;****************************************************************************** //;sed1330 funtion Write_Reg(unsigned char command) { R_D = 1; RS = 0; CS1 = 0; W_R = 0; Data_BUS = command; W_R = 1; RS = 1; CS1 = 1; } //;****************************************************************************** Writ_Data(unsigned char data1) { R_D = 1; RS = 1; CS1 = 0; W_R = 0; Data_BUS = data1; W_R = 1; RS = 1; CS1 = 1; } //==================================================== Command_Write(unsigned char REG,unsigned char VALUE) { Write_Reg(REG); Writ_Data(VALUE); } //====================================================== SendData(unsigned int VALUE) { R_D = 1; //SET_nRD; RS = 1; //SET_RS; CS1 = 0; //CLR_CS1; W_R = 0; //CLR_nWRL; Data_BUS = ((VALUE)>>8); //DB8OUT(Dat16bit>>8); W_R = 1; //SET_nWRL; // Low to High Latch Data to FSA506 Buffer CS1 = 1; //SET_CS1; R_D = 1; //SET_nRD; RS = 1; //SET_RS; CS1 = 0; //CLR_CS1; W_R = 0; //CLR_nWRL; Data_BUS = VALUE; //DB8OUT(Dat16bit); W_R = 1; //SET_nWRL; // Low to High Latch Data to FSA506 Buffer CS1 = 1; //SET_CS1; } //====================================================== // initial //====================================================== void Initial_FSA506 (void) { Command_Write(0x40,0x12); //[7:6] Reserved //[5]PLL control pin 0:20Mhz~100Mhz 1:100Mhz~300Mhz //[4] Reserved [3] Reserved //[2:1] Output Driving Capability 00: 4mA 01: 8mA 10: 12mA 11: 16mA //[0] Output slew rate 0: Fast 1: Slow Command_Write(0x41,0x01); //Set PLL=40Mhz*(0x42)/(0x41) Command_Write(0x42,0x01); //0x41 [7:6] Reserved [5:0] PLL Programmable pre-divider, 6bit(1~63) //0x42 [7:6] Reserved [5:0] PLL Programmable loop divider, 6bit(1~63) Command_Write(0x00,0x00); // MSB of horizontal start coordinate value Command_Write(0x01,0x00); // LSB of horizontal start coordinate value Command_Write(0x02,0x01); // MSB of horizontal end coordinate value Command_Write(0x03,0x3F); // LSB of horizontal end coordinate value Command_Write(0x04,0x00); // MSB of vertical start coordinate value Command_Write(0x05,0x00); // LSB of vertical start coordinate value Command_Write(0x06,0x00); // MSB of vertical end coordinate value Command_Write(0x07,0xEF); // LSB of vertical end coordinate value Command_Write(0x08,0x01); // MSB of input image horizontal resolution Command_Write(0x09,0x40); // LSB of input image horizontal resolution Command_Write(0x0A,0x00); //[17:16] bits of memory write start address Command_Write(0x0B,0x00); //[15:8] bits of memory write start address Command_Write(0x0C,0x00); //[7:0] bits of memory write start address Command_Write(0x10,0x0D); //[7] Output data bits swap 0: Normal 1:Swap //[6] Output test mode enable 0: disable 1: enable //[5:4] Serial mode data out bus selection //00: X_ODATA17 ~ X_ODATA12 active , others are set to zero //01: X_ODATA11 ~ X_ODATA06 active , others are set to zero //10: X_ODATA05 ~ X_ODATA00 active , others are set to zero //11: reserved //[3] Output data blanking //0: set output data to 0 // 1: Normal display //[2] Parallel or serial mode selection //0: serial data out // //1: parallel data output[7:0] bits of memory write start address //[1:0] Output clock selection //00: system clock divided by 2 //01: system clock divided by 4 40M/4=10M(max) 6.5M(typ) //10: system clock divided by 8 //11: reserved Command_Write(0x11,0x05); //[7] Reserved // Command_Write(0x11,0x1B); //[7] Reserved //[6:4] Even line of serial panel data out sequence or data bus order of parallel panel //000: RGB //001: RBG //010: GRB //011: GBR //100: BRG //101: BGR Others: reserved //[3] Reversed //[2:0] Odd line of serial panel data out sequence //000: RGB //001: RBG //010: GRB //011: GBR //100: BRG //101: BGR Others: reserved Command_Write(0x12,0x00); //[7:4] Reserved [3:0] MSB of output H sync. pulse start position Command_Write(0x13,0x00); //[7:0] LSB of output H sync. pulse start position Command_Write(0x14,0x00); //[7:4] Reserved [3:0] MSB of output H sync. pulse width Command_Write(0x15,0x10); //[7:0] LSB of output H sync. pulse width Command_Write(0x16,0x00); //[7:4] Reserved [3:0] MSB of output DE horizontal start position Command_Write(0x17,0x44); //[7:0] LSB of output DE horizontal start position Command_Write(0x18,0x01); //[7:4] Reserved [3:0] MSB of output DE horizontal active region in pixel Command_Write(0x19,0x40); //[7:0] LSB of output DE horizontal active region in pixel Command_Write(0x1A,0x01); //[7:4] Reserved [3:0] MSB of output H total in pixel Command_Write(0x1B,0xB8); //[7:0] LSB of output H total in pixel Command_Write(0x1C,0x00); //[7:4] Reserved [3:0] MSB of output V sync. pulse start position Command_Write(0x1D,0x00); //[7:0] of output V sync. pulse start position Command_Write(0x1E,0x00); //[7:4] Reserved [3:0] MSB of output V sync. pulse width Command_Write(0x1F,0x08); //[7:0] LSB of output V sync. pulse width Command_Write(0x20,0x00); //[7:4] Reserved [3:0] MSB of output DE vertical start position Command_Write(0x21,0x13); //[7:0] LSB of output DE vertical start position Command_Write(0x22,0x00); //[7:4] Reserved [3:0] MSB of output DE vertical active region in line Command_Write(0x23,0xF0); //[7:0] LSB of output DE vertical active region in line Command_Write(0x24,0x01); //[7:4] Reversed [3:0] MSB of output V total in line Command_Write(0x25,0x09); //[7:0] LSB of output V total in line Command_Write(0x26,0x00); //[7:2] Reserved [1:0] [17:16] bits of memory read start address Command_Write(0x27,0x00); //[7:0] [15:8] bits of memory read start address Command_Write(0x28,0x00); //[7:0] [7:0] bits of memory read start address Command_Write(0x29,0x01); //[7:1] Reversed [0] Load output timing related setting (H sync., V sync. and DE) to take effect Command_Write(0x2D,0x08); //[7:4] Reserved [3] Output pin X_DCON level control //[2] Output clock inversion 0: Normal 1: Inverse //[1:0] Image rotate //00: 0�X 01: 90�X 10: 270�X 11: 180�X Command_Write(0x30,0x00); //[7:4] Reserved [3:0] MSB of image horizontal shift value Command_Write(0x31,0x00); //[7:0] LSB of image horizontal shift value Command_Write(0x32,0x00); //[7:4] Reserved [3:0] MSB of image vertical shift value Command_Write(0x33,0x00); //[7:0] LSB of image vertical shift value Command_Write(0x34,0x01); //[7:4] Reserved [3:0] MSB of image horizontal physical resolution in memory Command_Write(0x35,0x40); //[7:0] LSB of image horizontal physical resolution in memory Command_Write(0x36,0x00); //[7:4] Reserved [3:0] MSB of image vertical physical resolution in memory Command_Write(0x37,0xF0); //[7:0] LSB of image vertical physical resolution in memory } //====================================================== WindowSet(unsigned int s_x,unsigned int e_x,unsigned int s_y,unsigned int e_y) { Write_Reg(0x00); Writ_Data((s_x)>>8); Writ_Data(s_x); Writ_Data((e_x)>>8); Writ_Data(e_x); Writ_Data((s_y)>>8); Writ_Data(s_y); Writ_Data((e_y)>>8); Writ_Data(e_y); } //======================================= FULL_ON(unsigned int dat) { unsigned char x,y,z; WindowSet(0x0000,0x013f,0x0000,0x00ef); Write_Reg(0xc1); for(x=0;x<240;x++) { for(y= 0;y<40;y++) { for(z = 0;z<8;z++) { SendData(dat); } } } Write_Reg(0x80); } //======================================= FRAME() { // char x,y; unsigned int i,j; WindowSet(0x0000,0x013f,0x0000,0x00ef); Write_Reg(0xc1); for(j= 0 ;j<40;j++) { for(i=0;i<8;i++) { SendData(0xffff); // } } for(j=0;j<238;j++) { SendData(0xf800); //red for(i=0;i<159;i++) { SendData(0x0000); //blue SendData(0x0000); //blue } SendData(0x001f); //red } for(j= 0 ;j<40;j++) { for(i=0;i<8;i++) { SendData(0xffff); //red } } Write_Reg(0x80); } //======================================= SQUARE() { unsigned int i,j,k,l; WindowSet(0x0000,0x013f,0x0000,0x00ef); Write_Reg(0xc1); for(l=0;l<6;l++) { for(k = 0;k<20;k++) { for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0x0000); } for(i = 0;i<20;i++) { SendData(0xffff); } } } //=================== for(k = 0;k<20;k++) { for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0xffff); } for(i = 0;i<20;i++) { SendData(0x0000); } } } } Write_Reg(0x80); } //======================================= SQUARE1() { unsigned int i,j,k,l; WindowSet(0x0000,0x013f,0x0000,0x00ef); Write_Reg(0xc1); for(l=0;l<6;l++) { for(k = 0;k<20;k++) { for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0xffff); } for(i = 0;i<20;i++) { SendData(0xf800); } } } //=================== for(k = 0;k<20;k++) { for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0xf800); } for(i = 0;i<20;i++) { SendData(0xffff); } } } } Write_Reg(0x80); } //======================================= SQUARE2() { unsigned int i,j,k,l; WindowSet(0x0000,0x013f,0x0000,0x00ef); Write_Reg(0xc1); for(l=0;l<6;l++) { for(k = 0;k<20;k++) { for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0x07e0); } for(i = 0;i<20;i++) { SendData(0xffff); } } } //=================== for(k = 0;k<20;k++) { for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0xffff); } for(i = 0;i<20;i++) { SendData(0x07e0); } } } } Write_Reg(0x80); } //======================================= SQUARE3() { unsigned int i,j,k,l; WindowSet(0x0000,0x013f,0x0000,0x00ef); Write_Reg(0xc1); for(l=0;l<6;l++) { for(k = 0;k<20;k++) { for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0xffff); } for(i = 0;i<20;i++) { SendData(0x001f); } } } //=================== for(k = 0;k<20;k++) { for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0x001f); } for(i = 0;i<20;i++) { SendData(0xffff); } } } } Write_Reg(0x80); } //======================================= COLORBAR() { unsigned int i,j,k,l; WindowSet(0x0000,0x013f,0x0000,0x00ef); Write_Reg(0xc1); for(k = 0;k<120;k++) { for(j = 0;j<8;j++) { for(i = 0;i<13;i++) { SendData(0xf800); } } for(j = 0;j<8;j++) { for(i = 0;i<14;i++) { SendData(0x07e0); } } for(j = 0;j<8;j++) { for(i = 0;i<13;i++) { SendData(0x001f); } } } //=================== for(k = 0;k<120;k++) { for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0x0000); } } for(j = 0;j<8;j++) { for(i = 0;i<20;i++) { SendData(0xffff); } } } Write_Reg(0x80); } //======================================= //======================================= COLORBAR1() { unsigned int i,j,k,l; WindowSet(0x0000,0x013f,0x0000,0x00ef); Write_Reg(0xc1); for(j = 0;j<240;j++) { for(i = 0;i<80;i++) { SendData(0xf800); SendData(0x07e0); SendData(0x001f); SendData(0xffff); } } Write_Reg(0x80); } //======================================= SHOWPIC() { unsigned int x; unsigned char z; WindowSet(0x0000,0x013f,0x0000,0x00ef); Write_Reg(0xc1); for(x= 0;x<9600;x++) { for(z =0x80;z;z>>=1) { if( pic[x] & z) SendData(0xffff); else SendData(0x0000); } } Write_Reg(0x80); } //======================================= delay(unsigned char z) { unsigned char x,y,j; for(j=0;j