|
|
View previous topic :: View next topic |
Author |
Message |
prayami
Joined: 22 Dec 2004 Posts: 78
|
Graphics LCD COG Module with KS0724 Driver |
Posted: Wed Jun 08, 2005 7:32 pm |
|
|
Hi..
I got Graphics LCD COG module which has KS0724 driver.
Here I have posted the code that I have made to initialize this LCD.
I tried a lot but could not get success.
Can anybody have some code or any suggestion?
The LCD is from Clover Display and datasheet is at following address.
http://www.cloverdisplay.com/pdf/cv9007e.pdf
And datasheet for KS0724 is at
http://www.ortodoxism.ro/datasheets/SamsungElectronic/mXuytxq.pdf
Quote: |
#CASE
#include <18F4525.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,BROWNOUT,PUT,NOPBADEN,NOXINST,NOMCLR,NOLPT1OSC
#use delay(clock=20000000)
#define CS PIN_B0 //= LCD pin 21
#define RES PIN_B1 //= LCD pin 20
#define RS PIN_B2 //= LCD pin 19
#define WR PIN_B5 //= LCD pin 18
#define RD PIN_B4 //= LCD pin 17
#define DB0 PIN_D0 //= LCD pin 16-9
#define DB1 PIN_D1
#define DB2 PIN_D2
#define DB3 PIN_D3
#define DB4 PIN_D4
#define DB5 PIN_D5
#define DB6 PIN_D6
#define DB7 PIN_D7
int1 GHWWR= 1, GHWRD=1, GHWSTA=0, GHWCMD=0;
int1 DoNothing=1;
void sim_reset()
{
/* 1. Init data port setup (if required by port architecture) */
set_tris_b(0x00);
set_tris_d(0x00);
/* 2. Make C/D, /RD, /WR, /CE to outputs (if required by port architecture) */
// Check your processor hardware manual for which register to operate in order
// to configure I/O port pins as output
output_high(CS);
output_high(RD);
output_high(WR);
/* 3. Set LCD reset line /RST active low (if /RST is connected to a port bit) */
output_low(RES);
/* 4. Set LCD reset line /RST passive high (if /RST is connected to a port bit) */
output_high(RES);
}//sim_reset()
void simwrby(int1 adr, unsigned int8 dat)
{
//RES=1; //Added by Prashant for Testing
/* A: Set C/D line according to adr, Set /CE line active low */
if(adr==1)
{
output_high(RS);
}
else
{
output_low(RS);
}//if(adr==0)
output_low(CS);
/* B1: Make data port an output (if required by port architecture) */
// Check your processor hardware manual for which register to operate in order
// to configure DB port pins as outputs
set_tris_b(0x00);
set_tris_d(0x00);
output_low(WR);
/* B2: Write data to data port */
// DB = dat;
if(bit_test(dat,0))
{
output_high(DB0);
}
else
{
output_low(DB0);
}
if(bit_test(dat,1))
{
output_high(DB1);
}
else
{
output_low(DB1);
}
if(bit_test(dat,2))
{
output_high(DB2);
}
else
{
output_low(DB2);
}
if(bit_test(dat,3))
{
output_high(DB3);
}
else
{
output_low(DB3);
}
if(bit_test(dat,4))
{
output_high(DB4);
}
else
{
output_low(DB4);
}
if(bit_test(dat,5))
{
output_high(DB5);
}
else
{
output_low(DB5);
}
if(bit_test(dat,6))
{
output_high(DB6);
}
else
{
output_low(DB6);
}
if(bit_test(dat,7))
{
output_high(DB7);
}
else
{
output_low(DB7);
}
/* C: Set /WR active low, (Delay min 80 ns), */
output_low(WR);
/* D: Set /WR passive high */
output_high(WR);
/* E: Set /CE passive high */
output_high(CS);
}//simwrby
void ghw_io_init()
{
set_tris_b(0x00);
set_tris_d(0x00);
output_high(CS);
output_high(RD);
output_high(WR);
output_high(RES);
delay_ms(5);
simwrby(GHWCMD, 0xAE); /* Display Off */
simwrby(GHWCMD, 0xA5); /* Entire display on | (0-1) */
simwrby(GHWCMD, 0xA0); /* Set ADC Alternative DireCtion | (0-1) Normal vertical direction*/
simwrby(GHWCMD, 0xC0); /* Norm/reverse SHL | (0x00 or 0x08) */
simwrby(GHWCMD, 0xA3); /* LCD bias ratio 3) */
simwrby(GHWCMD, 0x20); /* Regulator resistor ration select | (0-7) */
simwrby(GHWCMD, 0x3F); /* Full Contrast-Reference Voltage Settings for contrast */
simwrby(GHWCMD, 0xA5); /* Normal display / Entire display on | (0-1) */
simwrby(GHWCMD, 0xAF); /* Display on */
delay_ms(5);
}//ghw_io_init()
void main() {
delay_ms(10);
ghw_io_init(); // Must initialize the LCD
for(;;) {
DoNothing=1;
}//for(;;)
}//main()
|
Thanks........ |
|
|
baronz Guest
|
|
Posted: Wed Jan 11, 2006 2:37 am |
|
|
this works on pic 16F876... i tried a lot to initialize it so i think it's nice to share the knowledge :D
int x=0;
output_high(SCLK);
delay_us(10);
output_high(CS1B);
delay_us(10);
output_high(RS);
delay_us(10);
output_high(RESETB);
delay_us(10);
output_low(RESETB);
// wait for stabilizing the power
delay_ms(300);
output_high(RESETB);
delay_ms(3);
output_low(CS1B);
delay_ms(3);
istruzione = 0xA0; // ADC Select -> reverse direction
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0xC8; // SHL Select -> normal direction //C0
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0xA2; // LCD Bias Select //A2
scrivi_controllo(istruzione);
delay_ms(3);
/* Attivazione in sequenza di VC,VR,VF */
istruzione = 0x2C; // power control -> voltage converter
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0x2E; // power control -> voltage regulator
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0x2F; // power control -> voltage follower
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0x24; // Regulatore resistor select //24
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0x81; // reference voltage (1a istruzione)
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0x13; // reference voltage (2a istruzione) //0x0C
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0xA4; // entire display OFF
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0xA6; // reverse display OFF
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0xB0; // set page address -> pagina 0
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0x40; // Initial display line
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0x10; // set column address MSB -> 0 (1a istruzione)
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0x00; // set column address LSB -> 0 (2a istruzione)
scrivi_controllo(istruzione);
delay_ms(3);
istruzione = 0xAF; // Display ON
scrivi_controllo(istruzione);
delay_ms(3);
clear_all();
void scrivi_controllo(char n){ // Daniele riscritta 16/12/2005 per microchip
signed int i=0;
int bit[8]={0,0,0,0,0,0,0,0};
output_low(RS); // RS = 0 istruzione di controllo
if (n & 0x80) bit[7]=1;
if (n & 0x40) bit[6]=1;
if (n & 0x20) bit[5]=1;
if (n & 0x10) bit[4]=1;
if (n & 0x08) bit[3]=1;
if (n & 0x04) bit[2]=1;
if (n & 0x02) bit[1]=1;
if (n & 0x01) bit[0]=1;
for (i=7;i>-1;i--){ // Manda i bit dal MSB al LSB
output_low(SCLK);
if (bit[i]==0) output_low(SID);
else output_high(SID);
output_high(SCLK);
} // for
} |
|
|
baronz Guest
|
|
Posted: Wed Jan 11, 2006 2:39 am |
|
|
i forgot to say that's the code for the serial command to the display |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|