//------------------------------------------------- // Shenzhen TOPWAY Technology Co.,Ltd. // LCD Module: LM12896F // Display Size: 128 x 96 // Driver/Controller: ST75161 // InterfaSCL: 80mode // by: wangxikuan // Date: 2019-7-11 // System; AT89S52 (12MHz) //------------------------------------------------- #include #include #include #define uchar unsigned char // 0~255 #define uint unsigned int // 0~65535 //----------------------------------- // ????????????????? 80mode #define LCDBUS P1 sbit RS = P3^6; sbit _CS = P3^4; sbit _RST = P3^5; sbit _WR = P3^7; sbit _RD = P3^2; uint ContrastLevel; // for contrast setting level uchar code logo[]= { /*-- ????x???=128x96 --*/ 0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x81,0x01,0x81, 0x01,0x81,0x01,0x81,0x01,0x81,0x01,0x81,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF, 0xFF,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20, 0x40,0x20,0x50,0xA0,0x50,0xA0,0x50,0xA8,0x50,0xA8,0x50,0xA8,0x54,0xA8,0x54,0xA8, 0x54,0xAA,0x54,0x2A,0x94,0x8A,0xD5,0xCA,0xE5,0xE2,0xF5,0xF2,0xF1,0xFA,0xF9,0xFC, 0xFD,0xFC,0xFC,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0x00,0x00,0x20,0x40,0x00,0xC0,0x40, 0x40,0x40,0x40,0x40,0x40,0xC0,0x00,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xC0, 0x00,0x00,0xE0,0x00,0x00,0x00,0xE0,0x00,0x00,0x40,0x40,0xC0,0x40,0x40,0x40,0x40, 0x00,0x00,0x80,0x80,0xA0,0xC0,0x80,0x80,0xC0,0xA0,0x80,0x80,0x80,0x00,0x80,0x40, 0x20,0xC0,0x00,0xE0,0x00,0xC0,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x40,0xA0,0x54,0xAA,0x55,0xAA,0x55,0x2A,0x95,0xCA,0xE5,0xF2,0xF9,0xFC, 0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x21,0xF2,0x08,0x80,0x88,0x4A, 0x29,0xFE,0x28,0x49,0x8A,0x88,0x00,0x42,0xC2,0x7F,0x22,0xA2,0x7F,0x00,0x00,0x7F, 0x00,0x00,0xFF,0x00,0x11,0x11,0xFF,0x09,0x15,0x08,0xFE,0x89,0x88,0x88,0xF8,0x00, 0x00,0x04,0x05,0x06,0xF4,0x57,0x54,0x54,0x57,0x54,0xF6,0x05,0x04,0x00,0x08,0xFC, 0x02,0x85,0x75,0x15,0xF5,0x45,0x9E,0x61,0x9F,0x01,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0, 0x54,0x2A,0x95,0xCA,0xE5,0xF2,0xF9,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x90,0x91,0x90,0x90,0x90,0x10, 0x10,0x11,0x90,0x90,0x90,0x10,0x10,0x10,0x90,0x90,0x91,0x90,0x10,0x90,0x10,0x10, 0x10,0x10,0x91,0x10,0x10,0x11,0x11,0x90,0x10,0x10,0x11,0x90,0x10,0x10,0x11,0x10, 0x90,0x10,0x10,0x10,0x11,0x11,0x91,0x11,0x11,0x11,0x11,0x90,0x10,0x10,0x10,0x11, 0x11,0x90,0x10,0x10,0x10,0x11,0x10,0x10,0x90,0x11,0x10,0x10,0x10,0x10,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x10,0x0A,0x65,0x70, 0x7C,0x7E,0x7F,0x7F,0x7D,0x7D,0x61,0x7D,0x7D,0x7F,0x73,0x6D,0x6D,0x6D,0x73,0x7F, 0x61,0x75,0x75,0x75,0x7B,0x7F,0x71,0x6F,0x77,0x6F,0x71,0x7F,0x67,0x73,0x75,0x73, 0x67,0x7F,0x7D,0x7B,0x67,0x7B,0x7D,0x7F,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00, 0x1E,0x21,0x40,0x40,0x40,0x21,0x1E,0x00,0x7F,0x08,0x08,0x08,0x07,0x01,0x1E,0x60, 0x18,0x07,0x00,0x07,0x18,0x60,0x1E,0x01,0x60,0x18,0x17,0x10,0x17,0x18,0x60,0x00, 0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x40, 0x02,0x7F,0x42,0x00,0x3C,0x42,0x42,0x24,0x7F,0x00,0x00,0x40,0x00,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0xF0,0xC0,0x00,0x00,0x00,0x00, 0x00,0xC0,0xF0,0xF0,0xF0,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xF0, 0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0x70,0x70,0x70,0xF0,0xE0, 0xE0,0x80,0x00,0x00,0x80,0xE0,0xE0,0xF0,0x70,0x70,0x70,0xF0,0xE0,0xE0,0x80,0x00, 0x00,0x80,0xC0,0xE0,0xF0,0x70,0x70,0x70,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,0xC0, 0xE0,0xE0,0x70,0x70,0x70,0xF0,0xE0,0xE0,0x80,0x00,0x00,0x00,0xF0,0xF0,0xF0,0x70, 0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x07,0x7F,0xFE,0xF0,0x00,0xF0, 0xFE,0x7F,0x07,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x07,0x03,0x03,0x01,0xFF, 0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x80,0xC0,0xE0,0xF0,0x78,0x3F, 0x1F,0x07,0x00,0x00,0xC7,0xEF,0xFF,0x7C,0x38,0x38,0x38,0x7C,0xFF,0xEF,0xC7,0x00, 0x00,0x0F,0x3F,0x3F,0x78,0x70,0x70,0x70,0x38,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0xFF, 0xFF,0x38,0x1C,0x1C,0x1C,0x3C,0xF9,0xF9,0xE1,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x38, 0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C, 0x1C,0x1C,0x1C,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x07,0x1F,0x1F,0x1F, 0x07,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F, 0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x18,0x1E,0x1F,0x1F,0x1F,0x1D,0x1C,0x1C,0x1C, 0x1C,0x1C,0x00,0x00,0x03,0x0F,0x0F,0x1E,0x1C,0x1C,0x1C,0x1E,0x0F,0x0F,0x03,0x00, 0x00,0x03,0x0F,0x0F,0x1E,0x1C,0x1C,0x1C,0x0E,0x0F,0x07,0x01,0x00,0x00,0x01,0x07, 0x0F,0x1E,0x1C,0x1C,0x1C,0x1E,0x0F,0x07,0x03,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x10,0x08,0xFC,0x00,0x00,0x00,0x08,0x04,0x84,0x44, 0x38,0x00,0xD8,0x24,0x24,0x24,0xD8,0x00,0x10,0x20,0xC0,0x20,0x10,0x00,0x38,0x44, 0x44,0x44,0xF8,0x00,0xF8,0x24,0x24,0x24,0xC8,0x00,0x00,0x00,0x00,0xFC,0x44,0x44, 0x44,0x38,0x00,0xF4,0x00,0x10,0x20,0xC0,0x20,0x10,0x00,0xE0,0x50,0x50,0x50,0x60, 0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x24, 0x24,0x44,0x44,0x88,0x00,0x04,0x04,0xFC,0x04,0x04,0x00,0x04,0x84,0x64,0x1C,0x04, 0x00,0x30,0x2C,0x24,0x24,0xC4,0x00,0x10,0x08,0xFC,0x00,0x00,0x00,0xF8,0x24,0x24, 0x24,0xC8,0x00,0x10,0x08,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x80,0x80,0x80,0x82,0x83,0x82,0x82, 0x82,0x80,0x81,0x82,0x82,0x82,0x81,0x80,0x82,0x81,0x80,0x81,0x82,0x80,0x81,0x82, 0x82,0x82,0x81,0x80,0x81,0x82,0x82,0x82,0x81,0x80,0x80,0x80,0x80,0x83,0x80,0x80, 0x80,0x80,0x80,0x83,0x80,0x82,0x81,0x80,0x81,0x82,0x80,0x81,0x82,0x82,0x82,0x81, 0x80,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x81,0x82, 0x82,0x82,0x82,0x81,0x80,0x80,0x80,0x83,0x80,0x80,0x80,0x80,0x83,0x80,0x80,0x80, 0x80,0x81,0x82,0x82,0x82,0x81,0x80,0x80,0x80,0x83,0x80,0x80,0x80,0x81,0x82,0x82, 0x82,0x81,0x80,0x80,0x80,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xFF }; //----------------------------------- // Delay Routine //----------------------------------- void delayms(uint m) // 12MHz Xtal, close to ms value { uint j; uint i; for(i=0; i0x00) // ????????? { ContrastLevel--; // ?????????1 SdCmd(0xd7); } } //----?????????----------------- void ClearRAM() { uchar i,j; SdCmd(0x30); //Extension Command 1 SdCmd(0xf0); // Display Mode SdData(0x10); // 10H=Monochrome Mode??11H=4Gray SdCmd(0x15);SdData(0x00);SdData(0x9f); // ?????е?? SdCmd(0x75);SdData(0x00);SdData(0x13); // ???????? SdCmd(0x5c); for(i=0;i<20;i++) { for(j=0;j<160;j++) { SdData(0x00); } } } /****************************************************************************/ void clear_ICON_RAM() { int j; SdCmd(0x30); //Extension Command 1 SdCmd(0x77); // Enable ICON RAM SdCmd(0x15); // Column Address Setting SdData(0x00); // SEG0 -> SEG255 SdData(0xff); SdCmd(0x5c); for(j=0;j<256;j++) { SdData(0x00); } SdCmd(0x76); // Disable ICON RAM } //----------------------------------- // ??????????Init LCD module //----------------------------------- void initLCDM(void) { _RST=0; delayms(2); _RST=1; delayms(800); //------OTP Set----------------- SdCmd(0x31); //Extension Command 2 SdCmd(0xd7); SdData(0x9f); // Auto Read Control? SdCmd(0xe0); SdData(0x00); // OTP WR/RD Control delayms(10); SdCmd(0xe3); // OTP Read delayms(20); SdCmd(0xe1); // OTP Control Out //------???????????????----------------------------------- ContrastLevel=0x00f2; // ???????????????? //------????????---------------------------------------------- SdCmd(0x30); //Extension Command 1 SdCmd(0x94); // Sleep out?? SdCmd(0xae); // Display off delayms(50); SdCmd(0x20); SdData(0x0b); // Power Control SdCmd(0x81); // ???????? SdData(0x1e); // VOP=12.5V SdData(0x03); SdCmd(0x31); //Extension Command 2 SdCmd(0x32); // Analog Circuit set SdData(0x00); SdData(0x01); SdData(0x04); // 1/10bias SdCmd(0x51); SdData(0xfa); // Booster level x8 SdCmd(0x30); //Extension Command 1 SdCmd(0xf0); SdData(0x10); // Display mode SdData(0x10)?????SdData(0x11)4??? SdCmd(0x0c); // D0=0 LSB on bottom SdCmd(0xca); // Display Control SdData(0x00); SdData(0x5f); SdData(0x00); // 1/96duty SdCmd(0xbc); SdData(0x00); // Data scan direction SdCmd(0xa6); // Inversion Display SdCmd(0xa6)normal,SdCmd(0xa7)Inverse SdCmd(0x31); //Extension Command 2 //---Frame Rate---// SdCmd(0xf0); SdData(0x02); // 20HZ SdData(0x03); // 34.5 SdData(0x12); // 77 SdData(0x1c); //138 SdCmd(0xf2); // Temperature Range SdData(0x09); // TA=-31 SdData(0x14); // TB=-20 SdData(0x52); // TC=42 SdCmd(0xf4); // Temperature Gradient Compensation SdData(0x56); // SdData(0x34); // SdData(0x23); // SdData(0x00); // SdData(0x10); // SdData(0x53); // SdData(0x56); // SdData(0x53); // SdCmd(0x31); //Extension Command 2 SdCmd(0x40); // Internal Power Supply clear_ICON_RAM(); ClearRAM(); SdCmd(0xaf); // Display on } //-----???д???????--------------------------------- void ShowBMP(uchar *pstr) { uchar i,j; SdCmd(0x30); //Extension Command 1 SdCmd(0x15);SdData(0x00);SdData(0x7f); // ?????е?? SdCmd(0x75);SdData(0x00);SdData(0x0b); // ???????? SdCmd(0x5c); // д???? for(i=0;i<12;i++) { for(j=0;j<128;j++) { SdData(*pstr++); // д??????? } } } //----------------------------------- // Main Program //----------------------------------- void main() { SP=0x60; EA = 0; // disable interrupts _CS =1; RS =1; _RD =1; _WR =1; _RST =1; // hardware reset LCD module initLCDM(); ShowBMP(logo); while(1) { } } //end of program