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);
}
}
}
} |