原帖由 kkjason 於 2007-6-23 20:28 發表




可否分享心得
1.)我唔明個LCD 個Pin 12,13(RD/WR) 因為其他LCD 係共用的
2.) Pin 15(RES) 又點攪呢?

THX


Original I would like to post some portion of the C code here, but the system redirect me to a "Comming soon!" page and I can't post the code.

This LCD use 8080 MPU interface, so it use 2 pins (one for RD) and the other for WR, you can check the datasheet for details.

For pin 15, which is a Active LOW reset pin, which is used during the LCD init process.

TOP

You can simply use the circuit posted in previous posts as a reference. Datasheet of KS0713 can be found here

http://www.ortodoxism.ro/datashe ... tronic/mXyzvqzy.pdf

For the C source, I could provide the core portion, how to init, send commands etc. As I use
DS89C450, which is a high speed 8051 architecture uC, if you use 89S51 or  89S52 (normal speed),
you may have to adjust the timings. The core portion is:

Pin definitions:

/* Hardware */
#define LCD_DATA        P1
sbit LCD_WR         = P2^0;                  // write data (active LOW)
sbit LCD_RD                = P2^1;                 // read data (active LOW)
sbit LCD_CS         = P2^2;                  // chip select (active LOW)
sbit LCD_RS                = P2^3;                 // command/data selection: 0=command, 1=data (A0)
sbit LCD_RST         = P2^4;                 // reset (active LOW)

Key function declarations:

void lcdWriteData(uchar d);
void lcdWriteCommand(uchar c);
void lcdInit();       
void lcdClear();
void lcdGotoXY(uchar x, uchar y);        // (0-131, 0-7)
void lcdDisplayChr(uchar , FONT_DEF*) ;
void lcdDisplayStr(uchar* , FONT_DEF*) ;


Function definitions:

/*-------------------------------------------------------------------------------
Tempo for the LCD timing
-------------------------------------------------------------------------------*/
void lcdDelay(ulong u32Duration)
{
        ulong u32Delay;
        for (u32Delay=0; u32Delay<u32Duration; u32Delay++);
}

void lcdWriteData(uchar d) {
        LCD_DATA = d;                                                        // place data
        LCD_RS = 1;                                                                // write data
        LCD_RD = 1;
        LCD_WR = 0;
        LCD_CS = 0;                                                                // enable chip
        _nop_();_nop_();_nop_();                                // wait at least 80ns
        _nop_();_nop_();_nop_();                                // wait at least 80ns
//        lcdDelay(100);
        LCD_CS = 1;
        LCD_WR = 1;
        lcdDelay(10);
}

void lcdWriteCommand(uchar c) {
        LCD_DATA = c;                                                        // place data
        LCD_RS = 0;                                                                // write command
        LCD_RD = 1;
        LCD_WR = 0;
        LCD_CS = 0;                                                                // enable chip
        _nop_();_nop_();_nop_();                                // wait at least 80ns
        _nop_();_nop_();_nop_();                                // wait at least 80ns
//        lcdDelay(100);
        LCD_CS = 1;
        LCD_WR = 1;
        lcdDelay(10);
}

/*
        LCD Initialization
        lcdInit()
*/
void lcdInit(void)       
{
        lcdDelay(100);                                        // wait for power stable

        LCD_CS = 0;                                                // chip enable

        LCD_RST = 0;                                        // reset
        _nop_();_nop_();_nop_();
        _nop_();_nop_();_nop_();
        lcdDelay(100);                                        // wait for power stable
        LCD_RST = 1;
        _nop_();_nop_();_nop_();
        _nop_();_nop_();_nop_();


        lcdWriteCommand(0xA6);                        // Normal Display
        lcdWriteCommand(0xA0);                        // ADC normal
        lcdWriteCommand(0x2F);                        // Power Control 111
        lcdWriteCommand(0xC8);                        // Common Output Mode select (reversed)
        lcdWriteCommand(0xA2);                        // LCD Bias

        lcdWriteCommand(0xAC);                        // Static Inidcator OFF (double byte command)
        lcdWriteCommand(0x00);                        // Static Inidcator OFF

        lcdWriteCommand(0x24);                        // V5 Ra, Rb ratio (0x20-0x27)
        lcdWriteCommand(0xEE);                        // Read-Write-Modify OFF
        lcdWriteCommand(0x40);                        // start line = 0
        lcdWriteCommand(0xB0);                        // page = 0

        lcdWriteCommand(0x10);                        // Column = 0 (MSB)
        lcdWriteCommand(0x00);                        //                           (LSB)

        lcdWriteCommand(0x81);                        // Electronic Volume Set (double byte command)
        lcdWriteCommand(0x13);                        // Electronic Volume Register (0x00-0x3F)

        lcdWriteCommand(0xAF);                        // set display ON

        lcdClear();
}  

void lcdClear() {
        uint i, j;
        lcdWriteCommand(0xB0);                        // page = 0
        for (i=0;i<8;i++) {
                lcdWriteCommand(0xB0 | i);                // page = i
                lcdWriteCommand(0x10);                        // Column = 0 (MSB)
                lcdWriteCommand(0x00);                        //                           (LSB)
                for (j=0;j<132;j++) {
                        lcdWriteData(0x00);
                }
        }
}


/*
        X (0-131), Y (0-7)
        Note: X, Y here are screen coordinate (X is page, Y is column
*/
void lcdGotoXY(uchar x, uchar y) {
        lcdWriteCommand(0xB0 | y);                // page = y
        lcdWriteCommand(0x10 | ((x & 0xF0) >> 4));                // Column = 0 (MSB)
        lcdWriteCommand(x & 0x0F);                                                //                           (LSB)
}



void main(void) {
        uint i,j;

        delay_ms(50);

        delay_ms(100);

        lcdInit();       

        lcdClear();

while (1) {       

        delay_ms(4000);
        lcdClear();
        lcdWriteCommand(0xB0);                        // page = 0
        for (i=0;i<8;i++) {
                lcdWriteCommand(0xB0 | i);                // page
                lcdWriteCommand(0x10);                        // Column = 0 (MSB)
                lcdWriteCommand(0x00);                        //                           (LSB)
                for (j=0;j<132;j++) {
                        if ((i % 2) == 0)
                                lcdWriteData(0xFF);
                        else
                                lcdWriteData(0x00);
                }
        }

        delay_ms(4000);
        lcdClear();       
        lcdWriteCommand(0xB0);                        // page = 0
        for (i=0;i<8;i++) {
                lcdWriteCommand(0xB0 | i);                // page
                lcdWriteCommand(0x10);                        // Column = 0 (MSB)
                lcdWriteCommand(0x00);                        //                           (LSB)
                for (j=0;j<132;j++) {
                        if ((i % 2) == 0)
                                lcdWriteData(0x00);
                        else
                                lcdWriteData(0xFF);
                }
        }

        delay_ms(4000);
        lcdClear();
        lcdWriteCommand(0xB0);                        // page = 0
        for (i=0;i<8;i++) {
                lcdWriteCommand(0xB0 | i);                // page
                lcdWriteCommand(0x10);                        // Column = 0 (MSB)
                lcdWriteCommand(0x00);                        //                           (LSB)
                for (j=0;j<132;j++) {
                                lcdWriteData(0xF0);
                }
        }       

        delay_ms(4000);
        lcdClear();
        lcdGotoXY(0,0);
        lcdDisplayStr("HELLO WORLD!", &Font_System3x6);
        lcdGotoXY(10,2);
        lcdDisplayStr("HELLO WORLD!", &Font_System5x8);
        lcdGotoXY(20,4);
        lcdDisplayStr("Hello World!", &Font_System7x8);
        delay_ms(4000);

        lcdClear();
        lcdWriteCommand(0xB0);                        // page = 0
        for (i=0;i<8;i++) {
                lcdWriteCommand(0xB0 | i);                // page
                lcdWriteCommand(0x10);                        // Column = 0 (MSB)
                lcdWriteCommand(0x00);                        //                           (LSB)
                for (j=0;j<132;j++) {
                                lcdWriteData(0xFF);
                }
        }

        delay_ms(4000);
        lcdClear();
        lcdWriteCommand(0xB0);                        // page = 0
        for (i=0;i<8;i++) {
                lcdWriteCommand(0xB0 | i);                // page
                lcdWriteCommand(0x10);                        // Column = 0 (MSB)
                lcdWriteCommand(0x00);                        //                           (LSB)
                for (j=0;j<132;j++) {
                                lcdWriteData(0x00);
                }
        }

}
}

TOP

今天看過,解像度非常好,但背光不是太理想,剩下不多了,要買的快手,

TOP

ktktkt  大大的 c code 未識睇,只約知一二, 有了driver, 以後就好辦了. 大家最好save 起,

再多謝 ktktkt  大大

如果可以出個用c 的8051 ”hello world” 分享就very good!

TOP

我想問, 電容專家係邊度, 我都想買塊....

TOP

原帖由 hktvro 於 2007-6-22 06:08 發表


我買了一個 , 控制晶片是KS0713

will it ok to use that with 89s51 instead of 89s52??

thx

TOP

原帖由 winglim7 於 2007-6-26 18:29 發表

will it ok to use that with 89s51 instead of 89s52??

thx


YES. Actually you can control the LCD with any microcontroller (PIC, 8051, AVR etc.), the C code above are based on 8051 architecture (i.e. 8051, 89C51, 89S51, 89S52, and many more). To control the lcd, we just need to use the I/O port of the microcontroller. When we say the LCD controller is KS0713, it means that KS0713 command set (and control sequence) only, which is basically independent of the controlling microcontroller. If you don't mind to write PC program to control the LPT port, you can control the LCD with PC as well.

TOP

ktktkt,

What version of C are you using? I copy and pasted your C code into Keil and compile it, it generated a lot of syntax errors. Thanks.

TOP

ktktkt 兄, 送你一個字 '勁'    


TOP

原帖由 palm3tong 於 2007-6-26 22:10 發表
ktktkt,

What version of C are you using? I copy and pasted your C code into Keil and compile it, it generated a lot of syntax errors. Thanks.



I use Keil C as well, but I think you can't paste the code directly, as there is some header files for DS89C450, data type definition (such as the u32long etc.), font datatype and font bitmap array. You have to tailer the code a bit. I recommend:

you use standard datatype (such as int, unsigned char, etc.)
add the following functions:
void lcdWriteData(uchar d);
void lcdWriteCommand(uchar c);
void lcdInit();        
void lcdClear();
void lcdGotoXY(uchar x, uchar y);        // (0-131, 0-7)

Try the first few sections of the main
  to init the lcd
  to clear the lcd
  to display a pattern


If you want to display character, you must have the font and corresponding function definition, they can be found on the Internet easily (but you have to tailer it).

TOP