| ??? 10/31/02 14:21 Read: times |
#31746 - Help on Graphic LCD with KS0108 |
Hi all,
I'm using a 128x64 Graphics LCD based on the KS0108 and KS0107 drivers. My problem is that when writting to the LCD, the byte I send is altered by the LCD. 1 bit on 2 is not what I've sent... To demonstrate this, I've wrote a program which counts from 0 to 127 on the P2 port. When disconnecting the LCD, and measuring with an oscilloscope, all the bits are correct according to the counter. When connecting the LCD, bits 0,2,4 and 8 have somme irrelevant but periodic state !!! And idea ? Below is that I've done for both hardware and software The microcontroller is a 89c668 and I've wired the LCD like this : #define LCD_DI P0_0 #define LCD_RW P0_1 #define LCD_E P0_2 #define LCD_CS1 P0_3 #define LCD_CS2 P0_4 #define LCD_RST P0_5 #define LCD_DATA P2 Here under is my LCD software : /*------------------------------------------------------------------------------- LCD Initialization GLCD_LcdINIT() -------------------------------------------------------------------------------*/ void GLCD_LcdInit(void) { LCD_DATA=0; LCD_DI=0; LCD_RW=0; LCD_E=0; LCD_CS1=1; LCD_CS2=0; LCD_RST=1; pause(); LCD_RST=0; pause(); LCD_RST=1; pause(); LCD_CS1=1; LCD_CS2=0; GLCD_LcdInstructionWrite(0x3E); // Display OFF GLCD_LcdInstructionWrite(0xC0); GLCD_LcdInstructionWrite(0xB8); GLCD_LcdInstructionWrite(0x40); GLCD_LcdInstructionWrite(0x3F); // Display ON LCD_CS1=0; LCD_CS2=1; GLCD_LcdInstructionWrite(0x3E); // Display OFF GLCD_LcdInstructionWrite(0xC0); GLCD_LcdInstructionWrite(0xB8); GLCD_LcdInstructionWrite(0x40); GLCD_LcdInstructionWrite(0x3F); // Display ON GLCD_ClearScreen(); } /*------------------------------------------------------------------------------- Send datas to the LCD LcdDataWrite (U8 u8Data) u8Data = data to send to the LCD -------------------------------------------------------------------------------*/ void GLCD_LcdDataWrite (U8 u8Data) { LCD_DI = 1; // Data mode LCD_RW = 0; // write mode pause(); LCD_DATA = u8Data; // outbyte LCD_E = 1; pause(); LCD_E = 0; // strobe pause(); LCD_E = 1; pause(); } /*------------------------------------------------------------------------------- Send instruction to the LCD LcdDataWrite (U8 u8Instruction) u8Instruction = Instructino to send to the LCD -------------------------------------------------------------------------------*/ void GLCD_LcdInstructionWrite (U8 u8Instruction) { LCD_DI = 0; // Instruction mode LCD_RW = 0; // Write mode pause(); LCD_DATA = u8Instruction; LCD_E = 1; pause(); LCD_E = 0; // strobe pause(); LCD_E = 1; pause(); } /*------------------------------------------------------------------------------- Clear the LCD screen GLCD_ClearScren () -------------------------------------------------------------------------------*/ void GLCD_ClearScreen (void) { U8 u8Page=0xb8; U8 u8Colomn=0; GLCD_LcdInstructionWrite(0x40); for (u8Page = 0xb8; u8Page < 0xc0; u8Page++) { LCD_CS1=1; LCD_CS2=0; GLCD_LcdInstructionWrite(u8Page); for (u8Colomn = 0; u8Colomn < 128; u8Colomn++) { if (u8Colomn == 64) { LCD_CS1=0; // switch from left to right LCD_CS2=1; GLCD_LcdInstructionWrite(u8Page); } GLCD_LcdDataWrite (0x00); } } } and following is my test software : /*------------------------------------------------------------------------------- LCD Initialization GLCD_LcdINIT() -------------------------------------------------------------------------------*/ void GLCD_LcdInit(void) { LCD_DATA=0; LCD_DI=0; LCD_RW=0; LCD_E=0; LCD_CS1=1; LCD_CS2=0; LCD_RST=1; pause(); LCD_RST=0; pause(); LCD_RST=1; pause(); LCD_CS1=1; LCD_CS2=0; GLCD_LcdInstructionWrite(0x3E); // Display OFF GLCD_LcdInstructionWrite(0xC0); GLCD_LcdInstructionWrite(0xB8); GLCD_LcdInstructionWrite(0x40); GLCD_LcdInstructionWrite(0x3F); // Display ON LCD_CS1=0; LCD_CS2=1; //GLCD_LcdInstructionWrite(0x3F); // Display ON GLCD_LcdInstructionWrite(0xC0); GLCD_LcdInstructionWrite(0xB8); GLCD_LcdInstructionWrite(0x40); GLCD_LcdInstructionWrite(0x3F); // Display ON GLCD_ClearScreen(); } /*------------------------------------------------------------------------------- Send datas to the LCD LcdDataWrite (U8 u8Data) u8Data = data to send to the LCD -------------------------------------------------------------------------------*/ void GLCD_LcdDataWrite (U8 u8Data) { //LCD_E = 0; //pause(); LCD_DI = 1; // Data mode LCD_RW = 0; // write mode pause(); LCD_DATA = u8Data; // outbyte LCD_E = 1; pause(); LCD_E = 0; // strobe pause(); //LCD_DI = 0; // Instruction mode LCD_E = 1; pause(); } /*------------------------------------------------------------------------------- Send instruction to the LCD LcdDataWrite (U8 u8Instruction) u8Instruction = Instructino to send to the LCD -------------------------------------------------------------------------------*/ void GLCD_LcdInstructionWrite (U8 u8Instruction) { //LCD_E = 0; //pause(); LCD_DI = 0; // Instruction mode LCD_RW = 0; // Write mode pause(); LCD_DATA = u8Instruction; LCD_E = 1; pause(); LCD_E = 0; // strobe pause(); LCD_E = 1; pause(); } /*------------------------------------------------------------------------------- Clear the LCD screen GLCD_ClearScren () -------------------------------------------------------------------------------*/ void GLCD_ClearScreen (void) { U8 u8Page=0xb8; U8 u8Colomn=0; GLCD_LcdInstructionWrite(0x40); for (u8Page = 0xb8; u8Page < 0xc0; u8Page++) { LCD_CS1=1; LCD_CS2=0; GLCD_LcdInstructionWrite(u8Page); for (u8Colomn = 0; u8Colomn < 128; u8Colomn++) { if (u8Colomn == 64) { LCD_CS1=0; // switch from left to right LCD_CS2=1; GLCD_LcdInstructionWrite(u8Page); } GLCD_LcdDataWrite (0x00); } } } |
| Topic | Author | Date |
| Help on Graphic LCD with KS0108 | 01/01/70 00:00 | |
RE: Help on Graphic LCD with KS0108 | 01/01/70 00:00 |



